結果

問題 No.1218 Something Like a Theorem
ユーザー kkkk
提出日時 2021-01-29 10:34:09
言語 C
(gcc 12.3.0)
結果
TLE  
実行時間 -
コード長 1,193 bytes
コンパイル時間 720 ms
コンパイル使用メモリ 28,796 KB
実行使用メモリ 10,492 KB
最終ジャッジ日時 2023-09-09 05:13:03
合計ジャッジ時間 7,184 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <stdio.h>

#define u_int64 unsigned long long

int ori_pow(u_int64 base, u_int64 num, u_int64* ans)
{
	int isOver = 0;
	*ans = 1;
	u_int64 i = num;
	while (num != 0) {
		if (*ans * base < *ans) {
			isOver = 1;
			break;
		}
		*ans = *ans * base;
		num--;
	}
	return isOver;
}

int main(int argc, char* argv[])
{
	u_int64 n = 0;
	u_int64 z = 0;
	u_int64 ans = 0;
	u_int64 maxSize = 0;

	scanf("%lld%lld", &n, &z);

	if (0 != ori_pow(z, n, &ans)) {
		printf("No");
		return 0;
	}
	ori_pow(10, 6, &maxSize);

	if (n < 0 || 100 < n || z < 0 || maxSize < ans) {
		printf("No");
		return 0;
	}

	int		x = 1;
	int		y = 1;
	u_int64 xSize;
	u_int64 ySize;
	u_int64	check = 0;
	char	isOK = 0; // yes = 1, no = 0

	while (!isOK) {
		y = 1;
		check = 0;
		if (0 != ori_pow(x, n, &xSize)) {
			isOK = 0;
			break;
		}
		if (maxSize < xSize) {
			break;
		}
		while (check < ans) {
			if (0 != ori_pow(x, n, &ySize)) {
				isOK = 0;
				break;
			}
			check = xSize + ySize;
			if (check < xSize || check < ySize) {
				isOK = 0;
				break;
			}
			if (check == ans) {
				isOK = 1;
				break;
			}
			y++;
		}
		x++;
	}

	if (isOK) {
		printf("Yes");

	}
	else {
		printf("No");
	}
	
	return 0;
}
0