QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#490295 | #5747. Persian Casino | ucup-team1525# | WA | 2ms | 4652kb | C++20 | 982b | 2024-07-25 14:16:38 | 2024-07-25 14:16:39 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
const int mod=1e9+9;
#define ll long long
inline int ksm(int x,int y)
{
int ans=1;
for (;y;y/=2,x=(ll)x*x%mod)
if (y&1)
ans=(ll)ans*x%mod;
return ans;
}
const int N=100005;
int fac[N],inv[N];
int n,m;
int C(int x,int y)
{
return (ll)fac[x]*inv[y]%mod*inv[x-y]%mod;
}
void solve()
{
scanf("%d%d",&n,&m);
if (m<=30)
{
int x=1<<30;
if (x<(n-m))
{
puts("bankrupt");
return;
}
}
int ans=0;
for (int i=0;i<=m;++i)
(ans+=C(n,i))%=mod;
printf("%d\n",ans);
}
void prework()
{
n=100000;
fac[0]=1;
for (int i=1;i<=n;++i)
fac[i]=(ll)fac[i-1]*i%mod;
inv[n]=ksm(fac[n],mod-2);
for (int i=n;i;--i)
inv[i-1]=(ll)inv[i]*i%mod;
}
int main()
{
int t;
prework();
scanf("%d",&t);
while (t--)
solve();
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 2ms
memory: 4652kb
input:
4 2 1 4 1 3 2 57639 34614
output:
3 5 7 869788168
result:
wrong answer 2nd lines differ - expected: 'bankrupt', found: '5'