Korotkodul

N5. Шаг в будущее

Oct 31st, 2021 (edited)
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.13 KB | None | 0 0
  1. #include <iostream>
  2. #include <vector>
  3. #include <algorithm>
  4. #include <string>
  5. #include <cmath>
  6. #include <set>
  7. #include <map>
  8. using namespace std;
  9.  
  10. int main()
  11. {
  12. int n,m,k;
  13. cin>>n>>k>>m;
  14. string real_ans;
  15. cin>>real_ans;
  16. int N = n * 2;
  17. string ans="", A(k, '2') , C(m, '0');
  18. string to9 = "";
  19. if (N - k - m > 0){
  20. int B_sz = N - k - m;
  21. if (B_sz % 2 == 1){
  22. B_sz--;
  23. }
  24. string B(B_sz, '1');
  25. ans = A + B + C;
  26. }
  27. else{
  28. ans = A + C;
  29. }
  30. if ((int)ans.size() % 2 == 1) ans = '0' + ans;
  31. //cout<<ans<<'\n';
  32. reverse(ans.begin(), ans.end());
  33. for (int i = 0; i < N; i += 2){
  34. int nxt = (ans[i] - '0') + (ans[i+1] - '0') * 3;
  35. char l = nxt + 48;
  36. //cout<<"l = "<<l<<'\n';
  37. to9 += l;
  38. }
  39. reverse(to9.begin(), to9.end());
  40. cout<<to9<<'\n';
  41. if (to9 == real_ans) cout<<"OK\n";
  42. else cout<<"F*ckU\n";
  43. }
  44. /*
  45. 70 20 30
  46. 8888888888444444444444444444444444444444444444444444444000000000000000
  47. 70 21 30
  48. 2888888888844444444444444444444444444444444444444444444000000000000000
  49. */
  50.  
  51.  
  52.  
Add Comment
Please, Sign In to add comment