結果

問題 No.677 10^Nの約数
ユーザー bal4ubal4u
提出日時 2019-04-14 05:58:16
言語 C
(gcc 12.3.0)
結果
AC  
実行時間 1 ms / 2,000 ms
コード長 1,144 bytes
コンパイル時間 347 ms
コンパイル使用メモリ 29,720 KB
実行使用メモリ 4,368 KB
最終ジャッジ日時 2023-10-14 09:22:39
合計ジャッジ時間 1,370 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,352 KB
testcase_01 AC 1 ms
4,348 KB
testcase_02 AC 0 ms
4,368 KB
testcase_03 AC 0 ms
4,348 KB
testcase_04 AC 1 ms
4,352 KB
testcase_05 AC 1 ms
4,352 KB
testcase_06 AC 1 ms
4,356 KB
testcase_07 AC 1 ms
4,352 KB
testcase_08 AC 1 ms
4,348 KB
testcase_09 AC 0 ms
4,348 KB
testcase_10 AC 1 ms
4,348 KB
testcase_11 AC 1 ms
4,348 KB
testcase_12 AC 1 ms
4,352 KB
testcase_13 AC 0 ms
4,352 KB
testcase_14 AC 1 ms
4,348 KB
testcase_15 AC 1 ms
4,348 KB
testcase_16 AC 1 ms
4,352 KB
testcase_17 AC 0 ms
4,356 KB
testcase_18 AC 1 ms
4,348 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.c:34:5: 警告: 組み込み関数 ‘pow’ が非関数として宣言されました [-Wbuiltin-declaration-mismatch]
   34 | int pow[MAX][2];
      |     ^~~

ソースコード

diff #

// yukicoder: No.677 10^Nの約数
// 2019.4.13 bal4u

#include <stdio.h>

//// 高速入力
#if 0
#define gc() getchar_unlocked()
#define pc(c) putchar_unlocked(c)
#else
#define gc() getchar()
#define pc(c) putchar(c)
#endif
int in()    // 非負整数の入力
{
	int n = 0, c = gc();
	do n = 10 * n + (c & 0xf), c = gc(); while (c >= '0');
	return n;
}

void out(long long n)  // 正整数の表示(出力)
{
	int i;
	char b[40];

	i = 0; while (n) b[i++] = n % 10 + '0', n /= 10;
	while (i--) pc(b[i]);
	pc('\n');
}

#define MAX  400
int sz;
long long tbl[MAX];
int pow[MAX][2];
int factor[2] = { 2, 5 };

int main(void)
{
	int i, j, k, p, q, N;
	long long d, min, ugly;

	N = in();
	sz = (N + 1)*(N + 1);
	ugly = tbl[0] = 1, pow[0][0] = pow[0][1] = 0;
	for (k = 1; k < sz; k++) {
		min = 0;
		for (i = 0; i < k; i++) {
			for (j = 0; j < 2; j++) {
				if (pow[i][j] == N) continue;
				d = tbl[i] * factor[j];
				if (d > ugly && (min == 0 || d < min)) min = d, p = i, q = j;
			}
		}
		tbl[k] = ugly = min;
		pow[k][0] = pow[p][0] + (q == 0);
		pow[k][1] = pow[p][1] + (q == 1);
	}
	for (i = 0; i < sz; i++) out(tbl[i]);
	return 0;
}
0