Advertisement
mhdew

TImus 1079

Mar 21st, 2018
140
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.47 KB | None | 0 0
  1. #include<bits/stdc++.h>
  2.  
  3. using namespace std;
  4.  
  5. int a[1000000];
  6.  
  7. int main()
  8. {
  9. a[0]=0;
  10. a[1]=1;
  11. for(int i=2;i<=50000;i+=2){
  12. a[i]=a[i/2];
  13. a[i+1]=a[i/2]+a[i/2+1];
  14. }
  15. int n;
  16. for(;;){
  17. scanf("%d", &n);
  18. if(n==0)
  19. break;
  20. int mx=0;
  21. for(int i=0;i<=n;i++){
  22. if(a[i]>mx){
  23. mx=a[i];
  24. }
  25. }
  26. printf("%d\n", mx);
  27. }
  28. return 0;
  29.  
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement