結果
問題 | No.1770 N言っちゃダメゲーム (6) |
ユーザー |
|
提出日時 | 2021-12-03 16:24:01 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
RE
|
実行時間 | - |
コード長 | 913 bytes |
コンパイル時間 | 279 ms |
コンパイル使用メモリ | 32,768 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-07-05 20:10:00 |
合計ジャッジ時間 | 4,332 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 13 RE * 12 TLE * 1 -- * 18 |
ソースコード
#include <cstdio> const int Maxn=500; int n,k; int f[Maxn+5][Maxn+5]; bool vis[Maxn+5]; int main(){ scanf("%d%d",&n,&k); /*if(k&1){ if(k%4==1){ if((n-1)%(k+2)==0){ puts("0"); } else{ printf("%d\n",n-((n-1)/(k+2)*(k+2)+1)); } } else{ if((n-1)%(k+1)==0){ puts("0"); } else{ printf("%d\n",n-((n-1)/(k+1)*(k+1)+1)); } } } else{ if((n-1)%(k+1)==0){ puts("0"); } else{ // int val_1=n- } }*/ for(int i=0;i<=k;i++){ f[0][i]=1; } for(int i=1;i<=n;i++){ for(int j=0;j<=k;j++){ for(int t=1;t<=i&&t<=k;t++){ if(t==j){ continue; } vis[f[i-t][t]]=1; } while(vis[f[i][j]]){ f[i][j]++; } for(int t=1;t<=i&&t<=k;t++){ if(t==j){ continue; } vis[f[i-t][t]]=0; } } } if(f[n][0]==0){ puts("0"); } else{ for(int i=1;i<=k;i++){ if(f[n-i][i]==0){ printf("%d\n",i); } } } return 0; }