結果

問題 No.314 ケンケンパ
ユーザー subsnsubsn
提出日時 2023-06-12 11:00:17
言語 C
(gcc 12.3.0)
結果
TLE  
実行時間 -
コード長 934 bytes
コンパイル時間 408 ms
コンパイル使用メモリ 28,412 KB
実行使用メモリ 62,960 KB
最終ジャッジ日時 2023-09-02 07:06:39
合計ジャッジ時間 4,930 ms
ジャッジサーバーID
(参考情報)
judge14 / judge16
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 TLE -
testcase_01 -- -
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 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <stdio.h>
#include <malloc.h>
#include <stdint.h>

int ptns = 0;
int n;
/// <summary>
/// 入力された数字を返す
/// </summary>
/// <returns></returns>
int ReadNum() {
	int negate = 0;
	char c = getchar();
	int num = 0;
	int numCnt = 0;
	while (c != '\n') {
		if (c == '-') {
			negate = 1;
		}
		else {
			num = num * 10 + c - '0';
		}

		c = getchar();
	}
	if (negate == 1) {
		num *= -1;
	}
	return num;
}

void reflex(int* nums,int cnt) {
	if (cnt < n) {
		for (int i = 0;i < 2;i++) {
			nums[cnt] = i;
			reflex(nums,cnt+1);
		}
	}
	if (cnt == n) {
		int ken = 0;
		for (int i = 0;i < n;i++) {
			if (nums[i] == 0) {
				ken++;
				if (ken == 3) return;
			}
			if (nums[i] == 1) {
				ken = 0;
				if (i == 0) return;
				if (nums[i - 1] == 1) return;
			}
		}
		ptns++;
	}
}

int main() {
	n = ReadNum();
	int* nums;
	nums = (int*)malloc(sizeof(int) * n);
	reflex(nums,0);
	printf("%d\n",ptns);
	free(nums);
}
0