|
|
back to boardWhy I get WA1(the result of my code is 3 4) Posted by Ilya 10 Jan 2021 03:54 #include <bits/stdc++.h> using namespace std; int main(){ int n; int a[100000]; a[0] = 0; a[1] = 1; int max = 1; while(cin >> n, n != 0){ if(n > max){ for(int i = max + 1; i <= n; ++i){ if(i % 2 == 0){ a[i] = a[i / 2]; } else{ a[i] = a[(i - 1) / 2] + a[(i - 1) / 2 + 1]; } max = n; } } cout << a[n - (n % 2 == 0)] << "\n"; } } Edited by author 10.01.2021 03:55 Re: Why I get WA1(the result of my code is 3 4) Posted by kitesho 12 Jan 2021 20:50 print the maximum value in the range 1 to n a13 is greater than a15 |
|
|