Advertisement
welleyth

207. Последовательность из 0 и 1

Dec 10th, 2020
918
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.52 KB | None | 0 0
  1. /********************
  2. * Problem: -.
  3. * Theme: Ukrainian 3 stage 2017 - 1
  4. */
  5. #include <bits/stdc++.h>
  6.  
  7. using namespace std;
  8.  
  9. #define int long long
  10. #define mp make_pair
  11. #define pb push_back
  12. #define ALL(A) A.begin(),A.end()
  13. #define RALL(A) A.rbegin(),A.rend()
  14. #define FOR(i,a,b) for(int i=(a);i<(b);i++)
  15. #define RFOR(i,a,b) for(int i=(a);i>=(b);i--)
  16. #define SZ(A) A.size()
  17. #define f first
  18. #define s second
  19.  
  20. typedef vector<int> VI;
  21. typedef vector<pair<int,int> > VII;
  22. typedef pair<int,int> pii;
  23. typedef pair<int,pair<int,int> > pip;
  24. typedef pair<pair<int,int>,pair<int,int> > ppp;
  25. typedef pair<pair<int,int>,int> ppi;
  26.  
  27. const long double PI=acos(-1);
  28. const int INF=(int)1e18;
  29. const int MOD=(int)1e9+7;
  30. const int N = 2e5+1;
  31.  
  32. void solve_case()
  33. {
  34.     int n;
  35.     cin >> n;
  36.  
  37.     __int128 a=1,b=1,c;
  38.  
  39.     for(int i=0;i<n;i++)
  40.     {
  41.         c = a;
  42.         a = a + b;
  43.         b = c;
  44.     }
  45.  
  46.     string ans = "";
  47.     while(a > 0)
  48.     {
  49.         ans = (char)((a%10) + 48) + ans;
  50.         a/=10;
  51.     }
  52.  
  53.     cout << ans;
  54.  
  55.     return;
  56. }
  57.  
  58. signed main()
  59. {
  60.     ios::sync_with_stdio(0); cin.tie(nullptr); cout.tie(nullptr);
  61. //    freopen("maximum.in","r",stdin);
  62. //    freopen("maximum.out","w",stdout);
  63.  
  64.     int t = 1;
  65. //    cin >> t;
  66.  
  67.     while(t--)
  68.     {
  69.         solve_case();
  70.     }
  71.  
  72.     return 0;
  73. }
  74.  
  75. /*
  76.  
  77. t*(t+1)/2 == n
  78.  
  79. t^2 + t - n == 0
  80.  
  81. D=1+4*n
  82.  
  83. x1 = (sqrt(D)+1)/2
  84.  
  85. 0 1 1 2 1 2 2 3 1  2  2  3  2  3  3  4
  86.  
  87. 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
  88.  
  89. 0 1 2 3 4 5 6 7 8  9 10 11 12 13 14 15
  90. */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement