#include <bits/stdc++.h> using namespace std; #define endl "\n" #define ll long long void solve(){ ll n,cnt,cnt2; cin >> n; cnt=0; while(cnt + 9 <= n){ cout << "9B"; cnt+=9; } if(n-cnt == 1){ cout << "B"; } if(cnt != n && n-cnt != 1){ cout << to_string(n-cnt) + "B"; } cnt=0; while(cnt + 9 <= n){ cout << "9D"; cnt+= 9; } if(n-cnt == 1){ cout << "D"; } if(cnt != n && n-cnt != 1){ cout << to_string(n-cnt) + "D"; } cnt=0; for(int i = n; i > 0; i--){ cout << "F"; cnt2=0; while(cnt2+9 < i){ cout << "9[BF]"; } if(i-1-cnt2 == 1){ cout << "BF"; } if(i-1-cnt2 == 2){ cout << "BFBF"; } if(cnt2 != i-1 && i-1-cnt2 != 1 && i-1-cnt2 != 2){ cout << to_string(i-1-cnt2) + "[BF]"; } cnt2=0; while(cnt2+9 < i){ cout << "9D"; } if(i-1-cnt2 == 1){ cout << "D"; } if(cnt2 != i-1 && i-1-cnt2 != 1){ cout << to_string(i-1-cnt2) + "D"; } } cout << endl; } int main(){ ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); //freopen("input.txt", "r", stdin); solve(); }
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 | #include <bits/stdc++.h> using namespace std; #define endl "\n" #define ll long long void solve(){ ll n,cnt,cnt2; cin >> n; cnt=0; while(cnt + 9 <= n){ cout << "9B"; cnt+=9; } if(n-cnt == 1){ cout << "B"; } if(cnt != n && n-cnt != 1){ cout << to_string(n-cnt) + "B"; } cnt=0; while(cnt + 9 <= n){ cout << "9D"; cnt+= 9; } if(n-cnt == 1){ cout << "D"; } if(cnt != n && n-cnt != 1){ cout << to_string(n-cnt) + "D"; } cnt=0; for(int i = n; i > 0; i--){ cout << "F"; cnt2=0; while(cnt2+9 < i){ cout << "9[BF]"; } if(i-1-cnt2 == 1){ cout << "BF"; } if(i-1-cnt2 == 2){ cout << "BFBF"; } if(cnt2 != i-1 && i-1-cnt2 != 1 && i-1-cnt2 != 2){ cout << to_string(i-1-cnt2) + "[BF]"; } cnt2=0; while(cnt2+9 < i){ cout << "9D"; } if(i-1-cnt2 == 1){ cout << "D"; } if(cnt2 != i-1 && i-1-cnt2 != 1){ cout << to_string(i-1-cnt2) + "D"; } } cout << endl; } int main(){ ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); //freopen("input.txt", "r", stdin); solve(); } |