提出 #1806337
ソースコード 拡げる
#include <bits/stdc++.h>
#define LL long long
using namespace std;
const int mo=1000000007;
int n,K,x; LL f[105][4000],ans,g[105][10005];
LL po(LL x,LL y){
LL z=1;
for (;y;y>>=1,x=x*x%mo)
if (y&1) z=z*x%mo;
return z;
}
int main(){
scanf("%d%d",&n,&K);
f[n+1][0]=1;
for (int i=n;i;--i){
for (int k=0;k<4000;++k)
if (f[i+1][k]){
for (int j=0;j<=K;++j){
if (j>i) (f[i][k]+=f[i+1][k])%=mo;
else (f[i][k+(j+k)/i]+=f[i+1][k])%=mo;
}
}
}
g[0][0]=1;
for (int i=1;i<=n;++i)
for (int k=0;k<=n*K;++k)
if (g[i-1][k]){
for (int j=0;j<=K;++j) (g[i][j+k]+=g[i-1][k])%=mo;
}
for (int k=0;k<=n*K;++k) (ans+=1ll*k*g[n][k])%=mo;
for (int k=0;k<4000;++k) (ans-=1ll*f[1][k]*k)%=mo;
printf("%lld\n",(ans%mo+mo)%mo);
return 0;
}
提出情報
| 提出日時 | |
|---|---|
| 問題 | G - Mancala |
| ユーザ | cyz666 |
| 言語 | C++14 (GCC 5.4.1) |
| 得点 | 1000 |
| コード長 | 777 Byte |
| 結果 | AC |
| 実行時間 | 114 ms |
| メモリ | 8960 KiB |
コンパイルエラー
./Main.cpp: In function ‘int main()’:
./Main.cpp:13:21: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
scanf("%d%d",&n,&K);
^
ジャッジ結果
| セット名 | sample | All | ||||
|---|---|---|---|---|---|---|
| 得点 / 配点 | 0 / 0 | 1000 / 1000 | ||||
| 結果 |
|
|
| セット名 | テストケース |
|---|---|
| sample | sample-01.txt, sample-02.txt |
| All | sample-01.txt, sample-02.txt, 01-01.txt, 01-02.txt, 01-03.txt, 01-04.txt, 01-05.txt, 01-06.txt, 01-07.txt, 01-08.txt, 01-09.txt, 01-10.txt, 01-11.txt, 01-12.txt, 01-13.txt, 01-14.txt, 01-15.txt, 01-16.txt, 01-17.txt, 01-18.txt, sample-01.txt, sample-02.txt |
| ケース名 | 結果 | 実行時間 | メモリ |
|---|---|---|---|
| 01-01.txt | AC | 2 ms | 2304 KiB |
| 01-02.txt | AC | 2 ms | 2304 KiB |
| 01-03.txt | AC | 2 ms | 2304 KiB |
| 01-04.txt | AC | 29 ms | 8832 KiB |
| 01-05.txt | AC | 3 ms | 8704 KiB |
| 01-06.txt | AC | 3 ms | 8704 KiB |
| 01-07.txt | AC | 12 ms | 8704 KiB |
| 01-08.txt | AC | 82 ms | 8960 KiB |
| 01-09.txt | AC | 111 ms | 8960 KiB |
| 01-10.txt | AC | 113 ms | 8960 KiB |
| 01-11.txt | AC | 114 ms | 8960 KiB |
| 01-12.txt | AC | 3 ms | 6528 KiB |
| 01-13.txt | AC | 16 ms | 8704 KiB |
| 01-14.txt | AC | 2 ms | 4480 KiB |
| 01-15.txt | AC | 26 ms | 8832 KiB |
| 01-16.txt | AC | 35 ms | 6784 KiB |
| 01-17.txt | AC | 2 ms | 2304 KiB |
| 01-18.txt | AC | 17 ms | 8832 KiB |
| sample-01.txt | AC | 2 ms | 2304 KiB |
| sample-02.txt | AC | 2 ms | 2432 KiB |