ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#204558 | #3615. 数糖果 | drdilyor | 100 | 1177ms | 48068kb | C++ | 1.1kb | 2024-06-02 10:19:26 | 2024-06-02 12:12:07 |
answer
#include<bits/stdc++.h>
using namespace std;
#define int long long
const int mod=1e9+7;
int fac[3000005],ifac[3000005];
int qkp(int b,int p){
int r=1;
while(p){
if(p&1)(r*=b)%=mod;
p/=2;
(b*=b)%=mod;
}
return r;
}
int C(int n,int m){
if(n<m)return 0;
return fac[n]*ifac[m]%mod*ifac[n-m]%mod;
}
void solve(){
int c0,c1,c2;
cin>>c0>>c1>>c2;
int coef=C(c1+c2+c0-1,c1+c2-1)*fac[c0]%mod*fac[c1]%mod*fac[c2]%mod;
//cout<<coef<<"\n";
//-1 -1 -1 1 1
//c1+c2
//x1+...+xn=c1+c2+c0
//1 1 1 1 1 1
//
//1 2 4 5
//2 3 5 6
//3 4 6 7
int cnt=0;
if(c2==c1-2||c2==c1-1||c2==c1+1||c2==c1+2){cnt++;}
cout<<cnt*coef%mod<<"\n";
//c1+c2 任意穿插.
//x1+x2+...+xn=c1+c2+n.
//C(c1+c2+n-1,n-1)
//1 | 1|1|1
//正整数.
//-1 -1 1
//1 -1 1
}
signed main(){
fac[0]=1;
for(int i=1;i<=3000000;i++)fac[i]=fac[i-1]*i%mod;
ifac[3000000]=qkp(fac[3000000],mod-2);
for(int i=2999999;i>=0;i--){
ifac[i]=ifac[i+1]*(i+1)%mod;
}
int t;
cin>>t;
while(t--)solve();
return 0;
}
Details
小提示:点击横条可展开更详细的信息
Test #1:
score: 10
Accepted
time: 42ms
memory: 48068kb
input:
5 3 1 3 5 2 3 5 6 4 5 6 4 4 4 3
output:
720 181440 151347172 151347172 725760
result:
ok 5 lines
Test #2:
score: 10
Accepted
time: 27ms
memory: 48064kb
input:
5 5 5 3 2 4 2 3 5 3 1 1 2 4 4 2
output:
68428800 2016 518400 6 145152
result:
ok 5 lines
Test #3:
score: 10
Accepted
time: 45ms
memory: 48068kb
input:
5 2 3 1 1 2 4 3 4 3 5 3 2 5 3 1
output:
120 288 72576 181440 40320
result:
ok 5 lines
Test #4:
score: 10
Accepted
time: 25ms
memory: 48064kb
input:
300 288 168 170 157 66 68 4 150 148 196 243 244 180 146 148 46 203 205 290 11 12 220 177 176 21 137 ...
output:
947653602 533474068 507308393 125596329 164337320 60882520 452533043 401891273 291500104 697851533 4...
result:
ok 300 lines
Test #5:
score: 10
Accepted
time: 42ms
memory: 48064kb
input:
300 70 165 163 141 44 42 44 202 204 13 158 156 125 9 11 217 20 18 50 263 262 198 105 103 133 300 298...
output:
608459872 837718974 203852844 565805161 639798107 241747747 923610631 930603776 187433271 890387297 ...
result:
ok 300 lines
Test #6:
score: 10
Accepted
time: 35ms
memory: 48064kb
input:
300 48 110 109 33 237 236 292 256 258 122 120 121 266 254 255 200 299 300 111 296 297 169 164 162 37...
output:
186941209 100690166 900205206 47018857 293780807 758472925 337160787 477866808 452308288 738416547 5...
result:
ok 300 lines
Test #7:
score: 10
Accepted
time: 190ms
memory: 48064kb
input:
100000 135340 204749 204751 578020 673158 673159 682787 143339 143338 565257 348497 348495 236412 34...
output:
447249095 716600114 556651949 2467060 205167072 801789309 873483847 30641807 670250900 276575591 300...
result:
ok 100000 lines
Test #8:
score: 10
Accepted
time: 256ms
memory: 48064kb
input:
100000 764818 160867 160869 762008 515808 515809 209826 896991 896992 13174 48146 48147 500653 49016...
output:
294005921 470269560 395930390 810321885 293666994 419290596 757000037 254858646 502033465 622760212 ...
result:
ok 100000 lines
Test #9:
score: 10
Accepted
time: 255ms
memory: 48068kb
input:
100000 394295 631191 631189 978700 844255 844253 769570 136441 136443 461091 251615 251614 797598 13...
output:
916590405 125819448 198990209 652797416 907226043 29769427 360175978 141717526 858105718 267726715 9...
result:
ok 100000 lines
Test #10:
score: 10
Accepted
time: 260ms
memory: 48064kb
input:
100000 23773 587309 587308 354176 686904 686905 105122 861685 861687 909008 951263 951265 837647 282...
output:
954450525 14529932 516288037 535066063 25282558 253150829 293662444 178345066 29893834 180424456 963...
result:
ok 100000 lines
Extra Test:
score: 0
Extra Test Passed