ENG  RUSTimus Online Judge
Online Judge
Problems
Authors
Online contests
About Online Judge
Frequently asked questions
Site news
Webboard
Links
Problem set
Submit solution
Judge status
Guide
Register
Update your info
Authors ranklist
Current contest
Scheduled contests
Past contests
Rules
back to board

Discussion of Problem 1079. Maximum

Скажите, пожалуйста, хелп, что здесь не так?)
Posted by Ilya 11 Jan 2017 23:56
PS. У меня тесты проходит
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];
}