ENG  RUSTimus Online Judge
Online Judge
Problems
Authors
Online contests
About Online Judge
Frequently asked questions
Site news
Webboard
Links
Problem set
Submit solution
Judge status
Guide
Register
Update your info
Authors ranklist
Current contest
Scheduled contests
Past contests
Rules
back to board

Discussion of Problem 1079. Maximum

What is wrong
Posted by enick 7 Mar 2008 21:52
#include <stdio.h>
#include <stdlib.h>
int a[100];
int in[10];
int i,j,k;
int N;
int main()
{
  int res1;
  int res2;
  i=0;
  while (scanf("%d",&in[i]))
  {
  if (in[i]==0)
    break;
   i++;
  }
  //cout<<"dshfhfhdf"<<endl;
  j=0;
   while(in[j]!=0)
   {
    N=in[j];
    //if (N==0) return 0;
    a[0]=0;
    a[1]=1;
    for (i=2;i<=N/2+1;i++)
    {
      if (i%2==0)
      a[i]=a[i/2];
      else
       a[i]=a[i/2]+a[i/2+1];

    }
     i-=2;
     if (N%2==0)
      printf("%d\n",(a[i-1]+a[i]));

     else
     printf("%d\n",(a[i]+a[i+1]));
     j++;
   }
   return 0;
 }