#include<iostream> #include<list> #include<string> #include<cstring> #include<sstream> #include<cctype> #include<string.h> #include<algorithm> #include<cmath> #include<stack> #include<fstream> #include<cstdlib> #include<vector> #include<map> #include<utility> #include<iomanip> #include<queue> using namespace std; #define INF (1<<29) #define SET(a) memset(a,-1,sizeof(a)) #define ALL(a) a.begin(),a.end() #define CLR(a) memset(a,0,sizeof(a)) #define FILL(a,v) memset(a,v,sizeof(a)) #define PB push_back #define FOR(i,n) for(int i = 0;i<n;i++) #define PI acos(-1.0) #define EPS 1e-9 #define MP(a,b) make_pair(a,b) #define READ(f) freopen(f, "r", stdin) #define WRITE(f) freopen(f, "w", stdout) #define LL long long int main() { int tc,a[100000],mx,n,i; a[0]=0; a[1]=1; for(i=2;i<100000;i+=2) { a[i]=a[i/2]; a[i+1]=a[i/2]+a[i/2+1]; } //cin>>tc; while(cin>>n) { if(n==0) break; //cin>>n; mx=0; for(i=1;i<=n;i++) if(a[i]>mx) mx=a[i]; cout<<mx<<endl; } return 0; }
Monday, 13 August 2012
URAL 1079. Maximum Solution
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment