|  | 
|  | 
| back to board | Скажите, пожалуйста, хелп, что здесь не так?) Posted by Ilya  11 Jan 2017 23:56PS. У меня тесты проходитPSS. базовые)
 
 #include<iostream>
 #include<vector>
 using namespace std;
 
 int test(int a);
 vector<int> list;
 //vector<int> answers;
 
 int main()
 {
 list.push_back(0);
 list.push_back(1);
 int N;
 cin >> N;
 while (N != 0)
 {
 cout << test(N);
 //    answers.push_back(test(N));
 cin >> N;
 }
 //for (int i = 0; i < answers.size(); i++)
 //    cout << answers[i] << endl;
 return 0;
 }
 
 int test(int a)
 {
 int i = 2;
 if (a < list.size() && a % 2 == 0)
 return list[a - 1];
 else if (a < list.size() && a % 2 != 0)
 return list[a];
 else if (a >= list.size())
 i = list.size();
 for (i; i <= a; i++)
 {
 if (i % 2 == 0)
 list.push_back(list[i / 2]);
 else
 list.push_back(list[i / 2] + list[i / 2 + 1]);
 }
 if (a % 2 == 0)
 return list[a - 1];
 else
 return list[a];
 }
 | 
 | 
|