Advertisement
erfanul007

Timus 1079

Oct 30th, 2018
190
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.45 KB | None | 0 0
  1. #include<stdio.h>
  2. int main()
  3. {
  4. int n,a[100005],i,j,max;
  5. a[0]=0;
  6. a[1]=1;
  7. for(i=2;i<100000;i++){
  8. j=i/2;
  9. if(i%2==0){
  10. a[i]=a[j];
  11. }
  12. else{
  13. a[i]=a[j]+a[j+1];
  14. }
  15. }
  16. for(i=1;i<=10;i++){
  17. max=0;
  18. scanf("%d",&n);
  19. if(n==0) break;
  20. for(j=0;j<=n;j++){
  21. if(max<a[j])
  22. max=a[j];
  23. }
  24. printf("%d\n",max);
  25. }
  26. return 0;
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement