Submission #2927039
Source Code Expand
#include <iostream> #include <algorithm> #include <vector> #include <set> #include <map> #include <queue> #include <stack> #include <cstdio> #include <cstring> #include <math.h> using namespace std; typedef long long ll; typedef double D; typedef pair<int,int> P; #define M 1000000007 #define F first #define S second #define PB push_back ll dp[1005][2],n,k,p[1005],o[1005]; ll pw(ll x,ll y){ ll res=1; while(y){ if(y&1)res=res*x%M; x=x*x%M; y>>=1; } return res; } ll cm(ll x,ll y){ return p[x]*o[y]%M*o[x-y]%M; } int main(void){ cin>>n>>k; p[0]=1; o[0]=1; for(ll i=1;i<=n;i++){ p[i]=p[i-1]*i%M; o[i]=pw(p[i],M-2); } dp[0][0]=1; for(ll i=0;i<n;i++){ for(ll j=2;i+j<=n;j++){ if(j==k)dp[i+j][1]=(dp[i+j][1]+dp[i][0]*cm(n-i-1,j-1)%M*p[j-1]%M)%M; else dp[i+j][0]=(dp[i+j][0]+dp[i][0]*cm(n-i-1,j-1)%M*p[j-1]%M)%M; dp[i+j][1]=(dp[i+j][1]+dp[i][1]*cm(n-i-1,j-1)%M*p[j-1]%M)%M; } } printf("%lld\n",dp[n][1]); }
Submission Info
Submission Time | |
---|---|
Task | J - 指さし |
User | nxteru |
Language | C++14 (GCC 5.4.1) |
Score | 0 |
Code Size | 1100 Byte |
Status | WA |
Exec Time | 10 ms |
Memory | 256 KB |
Judge Result
Set Name | Sample | Subtask1 | All | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 0 / 10 | 0 / 140 | ||||||||||
Status |
|
|
|
Set Name | Test Cases |
---|---|
Sample | 00_example0.txt, 00_example1.txt, 00_example2.txt, 00_example3.txt |
Subtask1 | 10_rand_small_00.txt, 10_rand_small_01.txt, 10_rand_small_02.txt, 10_rand_small_03.txt, 10_rand_small_04.txt, 10_rand_small_05.txt, 10_rand_small_06.txt, 10_rand_small_07.txt, 10_rand_small_08.txt, 10_rand_small_09.txt, 10_rand_small_10.txt, 10_rand_small_11.txt, 10_rand_small_12.txt, 10_rand_small_13.txt, 10_rand_small_14.txt, 10_rand_small_15.txt, 10_rand_small_16.txt, 10_rand_small_17.txt, 10_rand_small_18.txt, 10_rand_small_19.txt, 10_rand_small_20.txt, 10_rand_small_21.txt, 10_rand_small_22.txt, 10_rand_small_23.txt, 10_rand_small_24.txt, 10_rand_small_25.txt, 10_rand_small_26.txt, 10_rand_small_27.txt, 10_rand_small_28.txt, 10_rand_small_29.txt |
All | 00_example0.txt, 00_example1.txt, 00_example2.txt, 00_example3.txt, 10_rand_small_00.txt, 10_rand_small_01.txt, 10_rand_small_02.txt, 10_rand_small_03.txt, 10_rand_small_04.txt, 10_rand_small_05.txt, 10_rand_small_06.txt, 10_rand_small_07.txt, 10_rand_small_08.txt, 10_rand_small_09.txt, 10_rand_small_10.txt, 10_rand_small_11.txt, 10_rand_small_12.txt, 10_rand_small_13.txt, 10_rand_small_14.txt, 10_rand_small_15.txt, 10_rand_small_16.txt, 10_rand_small_17.txt, 10_rand_small_18.txt, 10_rand_small_19.txt, 10_rand_small_20.txt, 10_rand_small_21.txt, 10_rand_small_22.txt, 10_rand_small_23.txt, 10_rand_small_24.txt, 10_rand_small_25.txt, 10_rand_small_26.txt, 10_rand_small_27.txt, 10_rand_small_28.txt, 10_rand_small_29.txt, 20_rand_00.txt, 20_rand_01.txt, 20_rand_02.txt, 20_rand_03.txt, 20_rand_04.txt, 20_rand_05.txt, 20_rand_06.txt, 20_rand_07.txt, 20_rand_08.txt, 20_rand_09.txt, 20_rand_10.txt, 20_rand_11.txt, 20_rand_12.txt, 20_rand_13.txt, 20_rand_14.txt, 20_rand_15.txt, 20_rand_16.txt, 20_rand_17.txt, 20_rand_18.txt, 20_rand_19.txt, 30_rand_max_0.txt, 30_rand_max_1.txt, 30_rand_max_2.txt, 30_rand_max_3.txt, 30_rand_max_4.txt, 30_rand_max_5.txt, 30_rand_max_6.txt, 30_rand_max_7.txt, 30_rand_max_8.txt, 30_rand_max_9.txt, 40_hand0.txt, 40_hand1.txt, 40_hand2.txt, 40_hand3.txt, 40_hand4.txt |
Case Name | Status | Exec Time | Memory |
---|---|---|---|
00_example0.txt | AC | 1 ms | 256 KB |
00_example1.txt | AC | 1 ms | 256 KB |
00_example2.txt | AC | 1 ms | 256 KB |
00_example3.txt | AC | 10 ms | 256 KB |
10_rand_small_00.txt | AC | 1 ms | 256 KB |
10_rand_small_01.txt | AC | 1 ms | 256 KB |
10_rand_small_02.txt | AC | 1 ms | 256 KB |
10_rand_small_03.txt | AC | 1 ms | 256 KB |
10_rand_small_04.txt | AC | 1 ms | 256 KB |
10_rand_small_05.txt | AC | 1 ms | 256 KB |
10_rand_small_06.txt | WA | 1 ms | 256 KB |
10_rand_small_07.txt | WA | 1 ms | 256 KB |
10_rand_small_08.txt | WA | 1 ms | 256 KB |
10_rand_small_09.txt | AC | 1 ms | 256 KB |
10_rand_small_10.txt | AC | 1 ms | 256 KB |
10_rand_small_11.txt | AC | 1 ms | 256 KB |
10_rand_small_12.txt | AC | 1 ms | 256 KB |
10_rand_small_13.txt | AC | 1 ms | 256 KB |
10_rand_small_14.txt | AC | 1 ms | 256 KB |
10_rand_small_15.txt | WA | 1 ms | 256 KB |
10_rand_small_16.txt | AC | 1 ms | 256 KB |
10_rand_small_17.txt | AC | 1 ms | 256 KB |
10_rand_small_18.txt | AC | 1 ms | 256 KB |
10_rand_small_19.txt | AC | 1 ms | 256 KB |
10_rand_small_20.txt | AC | 1 ms | 256 KB |
10_rand_small_21.txt | AC | 1 ms | 256 KB |
10_rand_small_22.txt | AC | 1 ms | 256 KB |
10_rand_small_23.txt | AC | 1 ms | 256 KB |
10_rand_small_24.txt | AC | 1 ms | 256 KB |
10_rand_small_25.txt | AC | 1 ms | 256 KB |
10_rand_small_26.txt | AC | 1 ms | 256 KB |
10_rand_small_27.txt | AC | 1 ms | 256 KB |
10_rand_small_28.txt | AC | 1 ms | 256 KB |
10_rand_small_29.txt | AC | 1 ms | 256 KB |
20_rand_00.txt | WA | 1 ms | 256 KB |
20_rand_01.txt | AC | 8 ms | 256 KB |
20_rand_02.txt | AC | 9 ms | 256 KB |
20_rand_03.txt | WA | 5 ms | 256 KB |
20_rand_04.txt | AC | 5 ms | 256 KB |
20_rand_05.txt | AC | 6 ms | 256 KB |
20_rand_06.txt | AC | 9 ms | 256 KB |
20_rand_07.txt | AC | 2 ms | 256 KB |
20_rand_08.txt | WA | 2 ms | 256 KB |
20_rand_09.txt | AC | 2 ms | 256 KB |
20_rand_10.txt | AC | 7 ms | 256 KB |
20_rand_11.txt | WA | 5 ms | 256 KB |
20_rand_12.txt | WA | 6 ms | 256 KB |
20_rand_13.txt | AC | 7 ms | 256 KB |
20_rand_14.txt | WA | 7 ms | 256 KB |
20_rand_15.txt | AC | 9 ms | 256 KB |
20_rand_16.txt | AC | 5 ms | 256 KB |
20_rand_17.txt | AC | 5 ms | 256 KB |
20_rand_18.txt | WA | 3 ms | 256 KB |
20_rand_19.txt | WA | 5 ms | 256 KB |
30_rand_max_0.txt | AC | 10 ms | 256 KB |
30_rand_max_1.txt | WA | 10 ms | 256 KB |
30_rand_max_2.txt | AC | 10 ms | 256 KB |
30_rand_max_3.txt | WA | 10 ms | 256 KB |
30_rand_max_4.txt | AC | 10 ms | 256 KB |
30_rand_max_5.txt | WA | 10 ms | 256 KB |
30_rand_max_6.txt | WA | 10 ms | 256 KB |
30_rand_max_7.txt | WA | 10 ms | 256 KB |
30_rand_max_8.txt | AC | 10 ms | 256 KB |
30_rand_max_9.txt | AC | 10 ms | 256 KB |
40_hand0.txt | AC | 1 ms | 256 KB |
40_hand1.txt | AC | 1 ms | 256 KB |
40_hand2.txt | AC | 10 ms | 256 KB |
40_hand3.txt | WA | 10 ms | 256 KB |
40_hand4.txt | AC | 10 ms | 256 KB |