結果

問題 No.1770 N言っちゃダメゲーム (6)
ユーザー SuiseisekiSuiseiseki
提出日時 2021-12-03 16:28:51
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
RE  
実行時間 -
コード長 1,257 bytes
コンパイル時間 243 ms
コンパイル使用メモリ 32,900 KB
実行使用メモリ 8,752 KB
最終ジャッジ日時 2023-09-19 08:23:10
合計ジャッジ時間 5,866 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
7,652 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 2 ms
4,380 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 2 ms
4,380 KB
testcase_06 RE -
testcase_07 RE -
testcase_08 AC 1 ms
4,384 KB
testcase_09 AC 2 ms
4,380 KB
testcase_10 AC 2 ms
4,376 KB
testcase_11 AC 2 ms
4,376 KB
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 AC 2 ms
4,380 KB
testcase_16 AC 3 ms
4,376 KB
testcase_17 RE -
testcase_18 AC 1 ms
4,384 KB
testcase_19 AC 2 ms
4,380 KB
testcase_20 AC 1 ms
4,380 KB
testcase_21 AC 1 ms
4,380 KB
testcase_22 AC 2 ms
4,376 KB
testcase_23 AC 2 ms
4,384 KB
testcase_24 RE -
testcase_25 WA -
testcase_26 AC 1 ms
4,376 KB
testcase_27 AC 2 ms
4,380 KB
testcase_28 WA -
testcase_29 AC 1 ms
4,380 KB
testcase_30 AC 1 ms
4,380 KB
testcase_31 WA -
testcase_32 TLE -
testcase_33 -- -
testcase_34 -- -
testcase_35 -- -
testcase_36 -- -
testcase_37 -- -
testcase_38 -- -
testcase_39 -- -
testcase_40 -- -
testcase_41 -- -
testcase_42 -- -
testcase_43 -- -
testcase_44 -- -
testcase_45 -- -
testcase_46 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#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));
			}
			return 0;
		}
	}
	else{
		if((n-1)%(k+1)==0){
			puts("0");
		}
		else{
			int val_1=n-((n-1)/(k+1)*(k+1)+1);
			int val_2=-1;
			for(int i=1;i<=k;i++){
				if(n-i-((n-i-1)/(k+1)*(k+1)+1)==i){
					val_2=i;
					break;
				}
			}
			if(val_2==-1){
				printf("%d\n",val_1);
			}
			else{
				if(val_1<val_2){
					printf("%d\n%d\n",val_1,val_2);
				}
				else{
					printf("%d\n%d\n",val_2,val_1);
				}
			}
		}
		return 0;
	}
	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;
}
0