UOJ Logo

NOI.AC

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#214812#2161. 小L的栈naroto202260131ms16748kbC++1.1kb2024-11-21 22:22:052024-11-22 09:37:35

answer

#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<cmath>
#define ll long long
using namespace std;
const int mod=1e9+7;
const int MN=1e6+5;
ll n,m,k,fac[MN],inv[MN];
void write(ll n){if(n<0){putchar('-');write(-n);return;}if(n>9)write(n/10);putchar(n%10+'0');}
ll read(){ll x=0,f=1;char ch=getchar();while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}while(ch>='0'&&ch<='9'){x=(x<<1)+(x<<3)+(ch^48);ch=getchar();}return x*f;}
ll ksm(ll a, ll b){ll res=1;while(b){if(b&1)res=(res*a)%mod;a=(a*a)%mod;b>>=1;}return res;}
void init(){fac[0]=1;for(int i=1; i<MN; i++) fac[i]=fac[i-1]*i%mod;inv[MN-1]=ksm(fac[MN-1],mod-2);for(int i=MN-2; i>=0; i--) inv[i]=inv[i+1]*(i+1)%mod;}
ll C(ll n, ll m){if(n<m)return 0;return fac[n]*inv[m]%mod*inv[n-m]%mod;}
ll cal(ll n, ll m){return (C(n+m,n)-C(n+m,m-1)%mod+mod)%mod;}
void solve(){
    n=read();m=read();k=read();
    if(m>n||k>m) write(0);
    else write(cal(m-1,m-k)*cal(n-m+k,n-m)%mod);
    putchar('\n');
}
int main(){
    init();
    ll T=read();while(T--)solve();
    return 0;
}

Details

小提示:点击横条可展开更详细的信息

Test #1:

score: 5
Accepted
time: 9ms
memory: 16744kb

input:

100
26 20 10
26 24 9
13 2 2
21 13 4
29 7 5
22 19 13
12 1 1
26 1 1
24 20 2
17 15 15
3 1 1
24 14 17
25...

output:

514423014
112607261
534888
381817972
555144047
73489416
208012
352943583
53685987
152
5
0
946367425
...

result:

ok 100 lines

Test #2:

score: 5
Accepted
time: 18ms
memory: 16744kb

input:

100
13 6 3
12 6 3
14 14 13
24 15 9
8 6 5
4 3 1
4 3 2
18 12 7
23 11 5
24 20 14
14 7 3
27 21 17
31 17 ...

output:

198016
56056
13
366737601
135
4
6
39504192
967067366
715926750
636480
64591509
0
671918485
796107692...

result:

ok 100 lines

Test #3:

score: 5
Accepted
time: 3ms
memory: 16744kb

input:

100
31 18 12
11 3 1
27 9 9
7 6 2
21 15 6
16 2 1
18 11 12
22 17 5
15 6 1
10 8 10
23 22 6
28 5 6
23 4 ...

output:

661234655
9724
815886766
126
267452475
9694845
0
656127752
705432
0
581024202
0
78189099
2674440
1
4...

result:

ok 100 lines

Test #4:

score: 5
Accepted
time: 13ms
memory: 16744kb

input:

100
25 22 14
7 5 6
6 1 1
7 1 1
7 4 2
8 5 1
8 2 1
18 4 5
5 4 3
18 9 7
11 10 6
4 2 1
15 4 2
3 1 1
3 1 ...

output:

594796736
0
132
429
140
196
429
0
12
33649000
3003
5
2674440
5
5
858
24310
823378651
935508470
0
856...

result:

ok 100 lines

Test #5:

score: 5
Accepted
time: 12ms
memory: 16748kb

input:

100
29 20 6
4 4 2
6 5 3
13 9 8
5 4 4
10 5 5
30 9 11
12 12 5
8 8 4
29 5 1
16 7 2
28 8 6
3 1 1
11 11 1...

output:

763947475
5
36
10080
5
1638
0
13260
165
249143859
5542680
630775223
5
1
56
534529540
293930
27971953...

result:

ok 100 lines

Test #6:

score: 5
Accepted
time: 11ms
memory: 16744kb

input:

100
5 5 5
26 22 4
19 17 16
25 17 8
31 2 2
28 21 12
15 3 1
31 8 2
22 1 1
15 3 2
3 2 2
25 17 3
15 3 3
...

output:

1
957177681
2720
337431182
462027062
923233078
1485800
116294070
482563003
3863080
3
549208528
43459...

result:

ok 100 lines

Test #7:

score: 5
Accepted
time: 11ms
memory: 16748kb

input:

10
474 293 237
481 396 187
364 43 45
741 78 8
158 53 30
463 445 433
120 110 62
503 52 16
360 318 32
...

output:

323352985
63241071
0
222507962
478641805
854383331
893261429
747110781
699961226
252997894

result:

ok 10 lines

Test #8:

score: 5
Accepted
time: 12ms
memory: 16744kb

input:

10
641 326 203
15 3 2
153 20 25
288 240 91
499 105 31
732 581 299
994 253 153
352 106 28
62 13 10
93...

output:

919680035
3863080
0
724023677
581680580
794343262
840693979
288065703
184728173
158286453

result:

ok 10 lines

Test #9:

score: 5
Accepted
time: 8ms
memory: 16744kb

input:

10
543 141 147
663 293 26
45 31 12
69 18 22
348 49 36
37 5 4
767 411 318
421 193 84
965 44 46
398 30...

output:

0
536162423
542866247
0
356102686
284316141
577945523
655525950
0
0

result:

ok 10 lines

Test #10:

score: 5
Accepted
time: 16ms
memory: 16748kb

input:

10
999 387 390
189 157 55
324 281 150
954 62 8
514 147 89
331 236 171
150 46 15
979 216 59
682 175 1...

output:

0
657224842
866062375
612350269
797998629
965804890
33283886
370426989
0
753780884

result:

ok 10 lines

Test #11:

score: 5
Accepted
time: 5ms
memory: 16744kb

input:

10
284 110 71
343 327 228
890 627 348
756 63 8
919 31 5
542 69 21
109 15 6
424 252 155
899 5 1
192 1...

output:

939661935
7427866
845407531
565632090
584793981
721121700
999456680
490287152
790372676
0

result:

ok 10 lines

Test #12:

score: 5
Accepted
time: 13ms
memory: 16744kb

input:

10
957 341 186
433 199 51
760 510 73
406 179 137
739 207 230
74 43 43
881 518 106
118 100 29
724 475...

output:

475101795
640352890
452627676
917987052
0
220718056
847304648
569168532
840548600
367170930

result:

ok 10 lines

Test #13:

score: 0
Runtime Error

input:

10000
948520 153123 37633
978977 610707 430315
861510 89319 84311
89854 76753 23361
539648 26973 539...

output:


result:


Test #14:

score: 0
Runtime Error

input:

10000
776217 468283 394226
679502 396921 440333
336294 175951 21262
158362 85737 87647
786586 679022...

output:


result:


Test #15:

score: 0
Runtime Error

input:

10000
727020 72982 84798
511326 476765 238661
768301 198556 241391
42904 770 3
225143 21785 19973
71...

output:


result:


Test #16:

score: 0
Runtime Error

input:

10000
349236 250424 6551
245300 155779 53345
718003 538775 455477
554195 3258 1970
864269 350613 163...

output:


result:


Test #17:

score: 0
Runtime Error

input:

10000
130797 50408 54584
589075 456571 10806
78159 33427 38224
303639 7008 8635
585821 448649 100079...

output:


result:


Test #18:

score: 0
Runtime Error

input:

10000
693060 190134 160913
997339 460961 184242
899251 525330 137457
513519 345024 295373
352825 155...

output:


result:


Test #19:

score: 0
Runtime Error

input:

10000
933167 891532 704848
80961 67286 35337
240488 174845 21388
451269 212850 49163
948517 31409 36...

output:


result:


Test #20:

score: 0
Runtime Error

input:

10000
61939 9116 2096
150659 75224 41401
13674 12474 10722
152304 47286 14033
319787 185775 135285
8...

output:


result: