fork(3) download
  1. #include <iostream>
  2. #include <stdio.h>
  3. using namespace std;
  4.  
  5. int main() {
  6. long long n,i;
  7. int T;
  8. clock_t t;
  9. t = clock();
  10. scanf("%d",&T);
  11. while(T-->0)
  12. {
  13. scanf("%lld",&n);
  14. long long first=0,second=1,sum=0; //0 1 1 2 3 5 8...
  15. // cout<<first<<" "<<second<<" ";
  16. for(i=0;i<n;i++)
  17. {
  18. sum=first+second; //sum=1,2
  19. first=second;//first=1,1
  20. second=sum;//second=1,2
  21. // printf("%lld ",sum);
  22. }
  23. // printf("\n");
  24. }
  25. t = clock() - t;
  26. double time_taken = ((double)t)/CLOCKS_PER_SEC; // in seconds
  27. printf("Program took %f seconds to execute \n", time_taken);
  28. return 0;
  29. }
Success #stdin #stdout 0s 3344KB
stdin
20
500000000
1000000000
1500000000
2000000000
2500000000
9000000000
2000000000
9124791742
8912741928471
12741491471941
500000000
1000000000
1500000000
2000000000
2500000000
9000000000
2000000000
9124791742
8912741928471
12741491471941
stdout
Program took 0.000000 seconds to execute