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 1513. Lemon Tale

WA#1 Who can find an error in my prog? =)
Posted by intueor 7 Feb 2014 18:47
I didn't use any long arithmethic but i think it should passes the first test. But judge says WA !!! Help please if you can


#include <iostream>

using namespace std;

long long d[10001][2];

int main () {
    int n, k;

    cin >> n >> k;

    d[0][0] = 1;
    d[0][1] = 0;

    int i, j;

    for (i = 1; i <= n; ++i) {

        d[i][1] = 0;
        for (j = 1; j <= k; ++j) {
            if (n - j < 0)
                continue;

            d[i][1] += d[i - j][0];
        }

        d[i][0] = d[i - 1][0] + d[i - 1][1];
    }

    cout << d[n][0] + d[n][1];

    return 0;
}