87902024-01-30 14:31:53QkrisiKiváló számok 2cpp17Wrong answer 13/1001.077s3972 KiB
#include <bits/stdc++.h>

using namespace std;

using ll = long long;

ll binomialCoeff(ll n, ll k) 
{ 
    ll res = 1; 
  
    if (k > n - k) 
        k = n - k; 
  
    for (ll i = 0; i < k; ++i) { 
        res *= (n - i) % 1000000007; 
        res /= (i + 1); 
    } 
  
    return res; 
}


int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);

    int T;
    cin >> T;
    while(T--)
    {
        ll S;
        cin >> S;
        int X;
        switch(S % 3)
        {
            case 0:
                X = 0;
                break;
            case 1:
                X = 2;
                break;
            case 2:
                X = 1;
                break;
        }
        ll NPlusK = (S-2*X)/3;
        ll ThreeNPlusK = S-(2*X);

        ll out = 0;
        //cout << "N+K: " << NPlusK << " X: " << X << endl;
        for(ll i = 0;i<NPlusK+1;i++)
        {
            //cout << i << " -> " << binomialCoeff(S, 3*i+X) << "\n";
            //cout << "3i+X: " << 3*i+X << '\n';
            out += binomialCoeff(S, (NPlusK-i)*3 + X);
            out %= 1000000007;
        }

        //cout << NPlusK << '\n';
        cout << out % 1000000007 << '\n';
        //cout << "1-től n+k-ig s alatt k summája" << '\n';
    }

    return 0;
}
SubtaskSumTestVerdictTimeMemory
subtask10/0
1Wrong answer4ms1896 KiB
subtask213/13
2Accepted3ms2116 KiB
3Accepted3ms2312 KiB
subtask30/24
4Wrong answer23ms2420 KiB
5Wrong answer35ms2488 KiB
6Wrong answer21ms2496 KiB
7Wrong answer28ms2616 KiB
subtask40/34
8Time limit exceeded1.077s2812 KiB
9Time limit exceeded1.074s3056 KiB
10Time limit exceeded1.077s3148 KiB
11Time limit exceeded1.054s3204 KiB
subtask50/29
12Time limit exceeded1.07s3316 KiB
13Time limit exceeded1.057s3528 KiB
14Time limit exceeded1.077s3632 KiB
15Time limit exceeded1.054s3764 KiB
16Time limit exceeded1.062s3844 KiB
17Time limit exceeded1.074s3972 KiB
18Time limit exceeded1.062s3956 KiB