8790 | 2024-01-30 14:31:53 | Qkrisi | Kiváló számok 2 | cpp17 | Wrong answer 13/100 | 1.077s | 3972 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;
}
Subtask | Sum | Test | Verdict | Time | Memory | ||
---|---|---|---|---|---|---|---|
subtask1 | 0/0 | ||||||
1 | Wrong answer | 4ms | 1896 KiB | ||||
subtask2 | 13/13 | ||||||
2 | Accepted | 3ms | 2116 KiB | ||||
3 | Accepted | 3ms | 2312 KiB | ||||
subtask3 | 0/24 | ||||||
4 | Wrong answer | 23ms | 2420 KiB | ||||
5 | Wrong answer | 35ms | 2488 KiB | ||||
6 | Wrong answer | 21ms | 2496 KiB | ||||
7 | Wrong answer | 28ms | 2616 KiB | ||||
subtask4 | 0/34 | ||||||
8 | Time limit exceeded | 1.077s | 2812 KiB | ||||
9 | Time limit exceeded | 1.074s | 3056 KiB | ||||
10 | Time limit exceeded | 1.077s | 3148 KiB | ||||
11 | Time limit exceeded | 1.054s | 3204 KiB | ||||
subtask5 | 0/29 | ||||||
12 | Time limit exceeded | 1.07s | 3316 KiB | ||||
13 | Time limit exceeded | 1.057s | 3528 KiB | ||||
14 | Time limit exceeded | 1.077s | 3632 KiB | ||||
15 | Time limit exceeded | 1.054s | 3764 KiB | ||||
16 | Time limit exceeded | 1.062s | 3844 KiB | ||||
17 | Time limit exceeded | 1.074s | 3972 KiB | ||||
18 | Time limit exceeded | 1.062s | 3956 KiB |