QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#87980#5747. Persian CasinochangtuWA 7ms4308kbC++201.4kb2023-03-14 22:19:452023-03-14 22:19:49

Judging History

你现在查看的是最新测评结果

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-03-14 22:19:49]
  • 评测
  • 测评结果:WA
  • 用时:7ms
  • 内存:4308kb
  • [2023-03-14 22:19:45]
  • 提交

answer

#include<iostream>
#include<algorithm>
#include<string.h>
#include<vector>
using namespace std;
// #define debug(x) cout<<"[debug]"#x<<"="<<x<<endl
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
const double eps=1e-8;
const int INF=0x3f3f3f3f,mod=1e9+9;

// #define ONLINE_JUDGE
#ifndef ONLINE_JUDGE
#define debug(...)
#include<debug>
#else
#define debug(...)
#endif

const int N=100005;
int fact[N],infact[N];
ll qmi(ll a,ll b,ll p)
{
    ll res=1;
    while(b)
    {
        if(b&1)
        res=res*a%p;

        a=a*a%p;
        b>>=1;
    }
    return res;
}
void init(int n)
{
    fact[0]=1;
    for(int i=1;i<=n;i++)
    {
        fact[i]=1ll*fact[i-1]*i%mod;
    }

    infact[n]=qmi(fact[n],mod-2,mod);
    for(int i=n-1;i>=0;i--)
    {
        infact[i]=1ll*infact[i+1]*(i+1)%mod;
    }
}
int C(int n,int m)
{
    if(n<m) return 0;
    return 1ll*fact[n]*infact[m]%mod*infact[n-m]%mod;
}
void solve()
{
    int n,m;
    scanf("%d%d",&n,&m);
    if(m<20&&(1<<m)+m<=n)
    {
        puts("bankrupt");
        return ;
    }

    if(m>n)
    {
        printf("%lld\n",qmi(2,n,mod));
        return ;
    }

    int res=C(n,m);
    for(int i=0;i<=m-1;i++)
    {
        res=(res+C(n,i))%mod;
    }
    printf("%d\n",res);
    return ;
}
int main()
{
    init(N-1);
    int T;
    scanf("%d",&T);
    while(T--)
    {
        solve();
    }
}

詳細信息

Test #1:

score: 100
Accepted
time: 0ms
memory: 4240kb

input:

4
2 1
4 1
3 2
57639 34614

output:

3
bankrupt
7
869788168

result:

ok 4 lines

Test #2:

score: -100
Wrong Answer
time: 7ms
memory: 4308kb

input:

16460
131 83
137 14
140 28
174 145
87 27
56 11
144 67
88 47
154 59
152 138
100 65
71 43
172 142
113 113
87 68
101 52
179 71
60 51
26 18
97 19
147 111
119 57
124 30
130 37
129 77
177 152
179 84
82 21
162 55
152 2
168 23
139 34
131 101
111 89
179 69
144 30
84 50
150 101
32 24
104 41
137 37
82 59
138 1...

output:

861401790
827411823
937669544
814872401
564368688
774329757
382020028
327399098
136919945
13075099
706031307
579851898
54033422
857164590
919274229
886008600
422741550
229676734
66137152
898506279
95608855
78287335
89291935
599857760
378517272
779874547
58872199
492901833
640116450
bankrupt
73638239...

result:

wrong answer 2678th lines differ - expected: '6196', found: 'bankrupt'