|
|
вернуться в форумWhy I get WA1(the result of my code is 3 4) Послано Ilya 10 янв 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) print the maximum value in the range 1 to n a13 is greater than a15 |
|
|