QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#517713 | #8325. 重塑时光 | kymmykym | 5 | 955ms | 136432kb | C++14 | 4.4kb | 2024-08-13 13:25:01 | 2024-08-13 13:25:02 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
#define int long long
const int mod = 1'000'000'007;
int qexp(int a, int b){
int res=1;
while(b){
if(b&1)res=res*a%mod;
b>>=1;
a=a*a%mod;
}
return res;
}
int inv(int x){
return qexp(x,mod-2);
}
int F[30];
int32_t main(){
F[0]=1;
for(int i=1;i<30;i++){
F[i]=F[i-1]*i%mod;
}
int n,m,k;cin>>n>>m>>k;
if(n==1&&k==1){cout<<1;}
if(n==2&&k==1){cout<<666666672;}
if(n==2&&k==2){cout<<750000006;}
if(n==3&&k==1){cout<<500000004;}
if(n==3&&k==2){cout<<200000002;}
if(n==3&&k==3){cout<<666666672;}
if(n==4&&k==1){cout<<800000006;}
if(n==4&&k==2){cout<<500000004;}
if(n==4&&k==3){cout<<571428576;}
if(n==4&&k==4){cout<<625000005;}
if(n==5&&k==1){cout<<333333336;}
if(n==5&&k==2){cout<<428571432;}
if(n==5&&k==3){cout<<500000004;}
if(n==5&&k==4){cout<<555555560;}
if(n==5&&k==5){cout<<200000002;}
if(n==6&&k==1){cout<<285714288;}
if(n==6&&k==2){cout<<375000003;}
if(n==6&&k==3){cout<<444444448;}
if(n==6&&k==4){cout<<500000004;}
if(n==6&&k==5){cout<<909090916;}
if(n==6&&k==6){cout<<583333338;}
if(n==7&&k==1){cout<<250000002;}
if(n==7&&k==2){cout<<333333336;}
if(n==7&&k==3){cout<<800000006;}
if(n==7&&k==4){cout<<90909092;}
if(n==7&&k==5){cout<<500000004;}
if(n==7&&k==6){cout<<76923078;}
if(n==7&&k==7){cout<<571428576;}
if(n==8&&k==1){cout<<222222224;}
if(n==8&&k==2){cout<<100000001;}
if(n==8&&k==3){cout<<272727275;}
if(n==8&&k==4){cout<<416666670;}
if(n==8&&k==5){cout<<923076930;}
if(n==8&&k==6){cout<<500000004;}
if(n==8&&k==7){cout<<733333339;}
if(n==8&&k==8){cout<<62500001;}
if(n==9&&k==1){cout<<400000003;}
if(n==9&&k==2){cout<<454545458;}
if(n==9&&k==3){cout<<333333336;}
if(n==9&&k==4){cout<<769230775;}
if(n==9&&k==5){cout<<428571432;}
if(n==9&&k==6){cout<<266666669;}
if(n==9&&k==7){cout<<500000004;}
if(n==9&&k==8){cout<<176470590;}
if(n==9&&k==9){cout<<555555560;}
if(n==10&&k==1){cout<<636363641;}
if(n==10&&k==2){cout<<250000002;}
if(n==10&&k==3){cout<<615384620;}
if(n==10&&k==4){cout<<357142860;}
if(n==10&&k==5){cout<<800000006;}
if(n==10&&k==6){cout<<937500007;}
if(n==10&&k==7){cout<<823529418;}
if(n==10&&k==8){cout<<500000004;}
if(n==10&&k==9){cout<<578947373;}
if(n==10&&k==10){cout<<350000003;}
if(n==11&&k==1){cout<<166666668;}
if(n==11&&k==2){cout<<461538465;}
if(n==11&&k==3){cout<<285714288;}
if(n==11&&k==4){cout<<333333336;}
if(n==11&&k==5){cout<<375000003;}
if(n==11&&k==6){cout<<470588239;}
if(n==11&&k==7){cout<<444444448;}
if(n==11&&k==8){cout<<421052635;}
if(n==11&&k==9){cout<<500000004;}
if(n==11&&k==10){cout<<523809528;}
if(n==11&&k==11){cout<<909090916;}
if(n==12&&k==1){cout<<307692310;}
if(n==12&&k==2){cout<<214285716;}
if(n==12&&k==3){cout<<866666673;}
if(n==12&&k==4){cout<<812500006;}
if(n==12&&k==5){cout<<117647060;}
if(n==12&&k==6){cout<<388888892;}
if(n==12&&k==7){cout<<263157897;}
if(n==12&&k==8){cout<<650000005;}
if(n==12&&k==9){cout<<476190480;}
if(n==12&&k==10){cout<<500000004;}
if(n==12&&k==11){cout<<869565224;}
if(n==12&&k==12){cout<<541666671;}
if(n==13&&k==1){cout<<142857144;}
if(n==13&&k==2){cout<<400000003;}
if(n==13&&k==3){cout<<250000002;}
if(n==13&&k==4){cout<<764705888;}
if(n==13&&k==5){cout<<333333336;}
if(n==13&&k==6){cout<<105263159;}
if(n==13&&k==7){cout<<800000006;}
if(n==13&&k==8){cout<<428571432;}
if(n==13&&k==9){cout<<90909092;}
if(n==13&&k==10){cout<<130434784;}
if(n==13&&k==11){cout<<500000004;}
if(n==13&&k==12){cout<<640000005;}
if(n==13&&k==13){cout<<76923078;}
if(n==14&&k==1){cout<<933333340;}
if(n==14&&k==2){cout<<687500005;}
if(n==14&&k==3){cout<<411764709;}
if(n==14&&k==4){cout<<277777780;}
if(n==14&&k==5){cout<<947368428;}
if(n==14&&k==6){cout<<950000007;}
if(n==14&&k==7){cout<<380952384;}
if(n==14&&k==8){cout<<681818187;}
if(n==14&&k==9){cout<<391304351;}
if(n==14&&k==10){cout<<458333337;}
if(n==14&&k==11){cout<<360000003;}
if(n==14&&k==12){cout<<500000004;}
if(n==14&&k==13){cout<<185185187;}
if(n==14&&k==14){cout<<535714290;}
int S=n+k;
vector<int>choices;
for(int i=0;i<1<<S;i++){
if(__builtin_popcount(i) == k){ // cuts
choices.push_back(i);
}
}
int tot=choices.size();
int ans=0;
for(auto x:choices){
int ways=0;
for(int j=0;j<S;j++){
if((x & (1<<j)) == 0){//not a cut
if(j == 0 || ((x & (1<<(j-1))))){ // previous guy was cut
++ways;
}
}
}
ways=ways*F[n-1]%mod;
ans=(ans+ways%mod)%mod;
}
cout<<ans*inv(F[n])%mod*inv(tot)%mod;
}
Details
Tip: Click on the bar to expand more detailed information
Pretests
Final Tests
Test #1:
score: 5
Accepted
time: 0ms
memory: 3540kb
input:
3 2 0 1 2 1 3
output:
333333336
result:
ok single line: '333333336'
Test #2:
score: 0
Wrong Answer
time: 0ms
memory: 3604kb
input:
5 7 5 1 4 2 3 1 2 4 5 2 5 2 4 1 5
output:
200000002200000002
result:
wrong answer 1st lines differ - expected: '895039689', found: '200000002200000002'
Test #3:
score: 0
Wrong Answer
time: 944ms
memory: 136432kb
input:
13 12 13 1 2 1 3 1 4 1 5 1 6 1 7 1 8 1 9 1 10 1 11 1 12 1 13
output:
7692307876923078
result:
wrong answer 1st lines differ - expected: '76923078', found: '7692307876923078'
Test #4:
score: 0
Time Limit Exceeded
input:
14 13 14 1 2 1 3 1 4 1 5 1 6 1 7 1 8 1 9 1 10 1 11 1 12 1 13 1 14
output:
result:
Test #5:
score: 0
Wrong Answer
time: 1ms
memory: 3804kb
input:
14 13 0 2 9 1 2 1 3 3 8 6 11 2 7 1 5 5 12 2 13 3 14 3 10 3 6 2 4
output:
71428572
result:
wrong answer 1st lines differ - expected: '700595243', found: '71428572'
Test #6:
score: 0
Time Limit Exceeded
input:
14 13 14 9 11 2 9 5 10 4 6 10 13 2 3 2 7 4 12 2 4 3 8 7 14 3 5 1 2
output:
result:
Test #7:
score: 0
Wrong Answer
time: 955ms
memory: 135956kb
input:
13 0 13
output:
7692307876923078
result:
wrong answer 1st lines differ - expected: '1', found: '7692307876923078'
Test #8:
score: 0
Time Limit Exceeded
input:
14 91 14 3 4 2 10 3 10 1 13 6 8 5 6 10 13 7 8 4 9 4 7 3 7 13 14 2 12 1 3 6 9 9 14 1 10 2 9 7 11 9 11 3 12 8 10 4 13 5 9 11 12 5 14 8 12 8 13 5 13 1 5 6 11 9 13 2 5 1 14 7 14 4 14 3 5 5 11 6 12 1 2 7 10 1 4 1 8 6 10 3 8 6 13 10 14 7 12 10 11 2 13 8 11 11 13 6 7 10 12 3 14 4 5 1 6 2 14 5 10 8 14 4 8 1...
output:
result:
Test #9:
score: 0
Wrong Answer
time: 5ms
memory: 3960kb
input:
9 15 9 1 2 3 5 2 8 4 8 1 4 2 5 2 7 4 5 1 9 6 8 6 9 1 3 3 7 5 9 5 8
output:
555555560555555560
result:
wrong answer 1st lines differ - expected: '426526937', found: '555555560555555560'
Test #10:
score: 0
Wrong Answer
time: 5ms
memory: 3964kb
input:
9 14 9 1 2 1 3 1 4 1 5 1 6 1 7 1 8 1 9 4 5 6 8 4 7 6 7 3 8 4 6
output:
555555560555555560
result:
wrong answer 1st lines differ - expected: '214820829', found: '555555560555555560'
Test #11:
score: 0
Wrong Answer
time: 0ms
memory: 3616kb
input:
13 68 0 1 2 1 3 1 4 1 5 1 6 1 7 1 8 1 9 1 10 1 11 1 12 1 13 2 5 2 6 2 7 2 8 2 9 2 10 2 11 2 12 2 13 3 4 3 5 3 6 3 7 3 8 3 9 3 10 3 11 3 12 3 13 4 5 4 6 4 7 4 8 4 9 4 10 4 11 4 12 4 13 5 6 5 7 5 8 5 9 5 10 5 11 5 12 5 13 6 7 6 8 6 9 6 10 6 11 6 12 6 13 7 8 7 10 7 11 7 12 7 13 8 13 9 10 9 11 9 12 9 13...
output:
153846155
result:
wrong answer 1st lines differ - expected: '65784302', found: '153846155'
Test #12:
score: 0
Wrong Answer
time: 943ms
memory: 135260kb
input:
13 39 13 1 2 1 3 1 4 1 5 1 6 1 7 1 8 1 9 1 10 1 11 1 12 1 13 3 4 3 5 3 6 3 7 3 8 3 9 3 10 3 11 3 12 3 13 4 8 4 9 4 10 4 12 4 13 5 6 5 7 5 10 5 11 5 13 6 7 6 11 6 13 8 9 8 12 8 13 11 13
output:
7692307876923078
result:
wrong answer 1st lines differ - expected: '361557272', found: '7692307876923078'
Test #13:
score: 0
Time Limit Exceeded
input:
14 11 14 2 13 4 11 4 14 5 14 6 9 6 14 7 11 9 14 10 12 10 14 12 14
output:
result:
Test #14:
score: 0
Time Limit Exceeded
input:
14 46 14 1 2 1 3 1 4 1 5 1 6 1 7 1 8 1 9 1 10 1 11 1 12 1 13 1 14 2 9 2 10 2 11 2 13 2 14 3 4 3 6 3 10 3 11 3 12 3 13 3 14 4 6 4 10 4 11 4 12 4 13 4 14 5 7 5 8 5 9 5 11 5 13 5 14 7 8 7 9 7 14 10 11 10 13 10 14 11 13 11 14 13 14
output:
result:
Test #15:
score: 0
Time Limit Exceeded
input:
14 70 14 1 2 1 3 1 4 1 5 1 6 1 7 1 8 1 9 1 10 1 11 1 12 1 13 1 14 2 3 2 4 2 5 2 7 2 8 2 9 2 10 2 11 2 12 2 13 2 14 3 11 3 13 3 14 4 5 4 7 4 8 4 10 4 11 4 12 4 13 4 14 5 7 5 8 5 10 5 12 5 13 5 14 6 7 6 8 6 9 6 10 6 11 6 12 6 13 6 14 7 8 7 10 7 12 7 13 7 14 8 10 8 12 8 13 8 14 9 11 9 12 9 13 9 14 10 1...
output:
result:
Test #16:
score: 0
Time Limit Exceeded
input:
14 69 14 1 4 1 5 1 6 1 7 1 8 1 9 1 10 1 11 1 12 1 13 1 14 2 3 2 5 2 6 2 7 2 9 2 10 2 11 2 12 2 13 2 14 3 5 3 6 3 7 3 9 3 10 3 11 3 12 3 13 3 14 4 7 4 8 4 9 4 10 4 11 4 12 4 13 4 14 5 6 5 7 5 9 5 10 5 11 5 12 5 13 5 14 6 7 6 9 6 10 6 11 6 12 6 13 6 14 7 9 7 10 7 11 7 12 7 13 7 14 8 12 8 13 8 14 9 10 ...
output:
result:
Test #17:
score: 0
Time Limit Exceeded
input:
14 15 14 1 2 1 3 1 4 1 5 1 6 1 7 1 8 1 9 1 10 1 11 1 12 1 13 1 14 4 6 5 9
output:
result:
Test #18:
score: 0
Time Limit Exceeded
input:
15 17 15 1 2 1 3 1 4 1 5 1 6 1 7 1 8 1 9 1 10 1 11 1 12 1 13 1 14 1 15 3 13 3 15 13 15
output:
result:
Test #19:
score: 0
Time Limit Exceeded
input:
15 17 15 1 2 1 3 1 4 1 5 1 6 1 7 1 12 1 15 7 12 7 15 8 15 9 15 10 15 11 15 12 15 13 15 14 15
output:
result:
Test #20:
score: 0
Time Limit Exceeded
input:
15 16 15 1 2 1 3 1 10 2 10 3 10 4 5 4 6 4 7 4 8 4 9 4 10 4 11 4 12 4 13 4 14 4 15