|
|
back to boardIf you want to know how to solve this problem, look here! :-) #include <iostream> using namespace std; unsigned nMax=0; unsigned n[10]; unsigned solveAns[100000]; short Count=-1; void Input() {unsigned nTec; cin>>nTec; while (nTec!=0) {Count++; n[Count]=nTec; if (nMax<nTec) nMax=nTec; cin>>nTec; } } void Solve() {solveAns[0]=0; solveAns[1]=1; for (int i=2; i<=nMax; i++) {solveAns[i]=solveAns[i/2]; i++; solveAns[i]=solveAns[i/2]+solveAns[(i/2)+1]; } } void Output() {unsigned Max; for (int i=0; i<=Count; i++) {Max=0; for (int j=0; j<=n[i]; j++) if (Max<solveAns[j]) Max=solveAns[j]; cout<<Max<<"\n"; } } int main() {Input(); Solve(); Output(); return 0; } |
|
|