fork(1) download
  1. #include "bits/stdc++.h"
  2. using namespace std;
  3.  
  4. void addBigNum(string& res, string a, string b){
  5. res = "";
  6. while (a.size() < b.size()) a = "0" + a;
  7. while (b.size() < a.size()) b = "0" + b;
  8. int cr = 0;
  9. for (int i = a.size()-1; i >= 0; i--){
  10. int t = a[i] + b[i] - 48*2 + cr;
  11. cr = t/10;
  12. t %= 10;
  13. res = (char)(t+48) + res;
  14. }
  15. if (cr) res = "1" + res;
  16. }
  17.  
  18. const int maxn = 1e4 + 10;
  19. string F[maxn];
  20. signed main(){
  21. ios_base::sync_with_stdio(false);
  22. cin.tie(0);
  23.  
  24. F[0] = "1";
  25. F[1] = "1";
  26. for (int i = 2; i <= 5000; i++){
  27. addBigNum(F[i], F[i-1], F[i-2]);
  28. }
  29. int n;
  30. cin >> n;
  31. while (cin >> n) cout << F[n] << "\n";
  32. }
Success #stdin #stdout 0.15s 6684KB
stdin
1
10000
stdout