結果

問題 No.384 マス埋めゲーム2
ユーザー taro305taro305
提出日時 2016-07-07 11:25:49
言語 C90
(gcc 11.4.0)
結果
TLE  
実行時間 -
コード長 605 bytes
コンパイル時間 125 ms
コンパイル使用メモリ 23,700 KB
実行使用メモリ 8,760 KB
最終ジャッジ日時 2023-08-03 00:57:43
合計ジャッジ時間 2,561 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
6,188 KB
testcase_01 TLE -
testcase_02 -- -
testcase_03 -- -
testcase_04 -- -
testcase_05 -- -
testcase_06 -- -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <stdio.h>
#include <time.h>

void check(int *a, int *b);

int main(void){
	int h, w, n, k, count = 1;

	scanf("%d %d %d %d", &h, &w, &n, &k);

	if (h > w) {
		h = h - w;
		w = 1;
	}
	else if(h < w) {
		w = w - h;
		h = 1;
	}
	else{
		h = 1;
		w = 1;
	}

	n = n - k;
	k = 1;

	for(;;){
		if(w == 1 && h == 1){
			if(count == k)
				printf("YES\n");
			else
				printf("NO\n");
			break;
		}
		if(h > w) check(&h, &w);
		else	  check(&w, &h);
		
		count++;
		if(count == n + 1)
			count = 1;
	}

	return 0;
}

void check(int *a, int *b){
	if(*a == 0){
		if(*b != 0)
			(*b)--;
	}
	else
		(*a)--;
}
0