結果

問題 No.1409 Simple Math in yukicoder
ユーザー 👑 ygussanyygussany
提出日時 2021-02-26 22:44:34
言語 C
(gcc 12.3.0)
結果
AC  
実行時間 423 ms / 2,000 ms
コード長 849 bytes
コンパイル時間 413 ms
コンパイル使用メモリ 33,544 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-04-10 13:26:31
合計ジャッジ時間 36,517 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
6,812 KB
testcase_01 AC 1 ms
6,944 KB
testcase_02 AC 1 ms
6,940 KB
testcase_03 AC 1 ms
6,944 KB
testcase_04 AC 1 ms
6,944 KB
testcase_05 AC 1 ms
6,940 KB
testcase_06 AC 1 ms
6,944 KB
testcase_07 AC 25 ms
6,944 KB
testcase_08 AC 86 ms
6,940 KB
testcase_09 AC 20 ms
6,944 KB
testcase_10 AC 67 ms
6,944 KB
testcase_11 AC 86 ms
6,940 KB
testcase_12 AC 70 ms
6,944 KB
testcase_13 AC 26 ms
6,940 KB
testcase_14 AC 24 ms
6,944 KB
testcase_15 AC 31 ms
6,944 KB
testcase_16 AC 29 ms
6,944 KB
testcase_17 AC 110 ms
6,944 KB
testcase_18 AC 51 ms
6,940 KB
testcase_19 AC 63 ms
6,940 KB
testcase_20 AC 47 ms
6,944 KB
testcase_21 AC 42 ms
6,944 KB
testcase_22 AC 71 ms
6,940 KB
testcase_23 AC 14 ms
6,944 KB
testcase_24 AC 14 ms
6,940 KB
testcase_25 AC 64 ms
6,944 KB
testcase_26 AC 76 ms
6,944 KB
testcase_27 AC 131 ms
6,940 KB
testcase_28 AC 130 ms
6,940 KB
testcase_29 AC 129 ms
6,944 KB
testcase_30 AC 127 ms
6,944 KB
testcase_31 AC 124 ms
6,944 KB
testcase_32 AC 123 ms
6,944 KB
testcase_33 AC 126 ms
6,940 KB
testcase_34 AC 117 ms
6,944 KB
testcase_35 AC 123 ms
6,944 KB
testcase_36 AC 132 ms
6,940 KB
testcase_37 AC 347 ms
6,940 KB
testcase_38 AC 354 ms
6,940 KB
testcase_39 AC 350 ms
6,940 KB
testcase_40 AC 370 ms
6,940 KB
testcase_41 AC 363 ms
6,944 KB
testcase_42 AC 352 ms
6,940 KB
testcase_43 AC 348 ms
6,944 KB
testcase_44 AC 358 ms
6,940 KB
testcase_45 AC 360 ms
6,940 KB
testcase_46 AC 367 ms
6,944 KB
testcase_47 AC 350 ms
6,940 KB
testcase_48 AC 356 ms
6,940 KB
testcase_49 AC 379 ms
6,940 KB
testcase_50 AC 371 ms
6,940 KB
testcase_51 AC 353 ms
6,940 KB
testcase_52 AC 369 ms
6,944 KB
testcase_53 AC 375 ms
6,944 KB
testcase_54 AC 368 ms
6,940 KB
testcase_55 AC 392 ms
6,940 KB
testcase_56 AC 383 ms
6,940 KB
testcase_57 AC 394 ms
6,944 KB
testcase_58 AC 398 ms
6,944 KB
testcase_59 AC 423 ms
6,940 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <stdio.h>

int Mod;

long long pow_mod(int n, int k)
{
	long long N, ans = 1;
	for (N = n; k > 0; k >>= 1, N = N * N % Mod) if (k & 1) ans = ans * N % Mod;
	return ans;
}

int main()
{
	int i, j, k, l, m, t, T, v, x, flag[100001];
	scanf("%d", &T);
	for (t = 1; t <= T; t++) {
		scanf("%d %d", &v, &x);
		Mod = v * x + 1;
		for (i = 1; i < Mod; i++) flag[i] = 0;
		
		for (i = 1, k = 0; i < Mod && k < x; i++) {
			if (flag[i] != 0) continue;
			if (pow_mod(i, x) == 1) flag[i] = 1;
			else flag[i] = -1;
			if (flag[i] == 1) {
				for (j = i * i % Mod, k++; j != i; j = j * i % Mod) {
					if (flag[j] == 0) {
						flag[j] = 1;
						k++;
					}
				}
			}
		}
		for (i = 1, j = 0; i < Mod && j < x; i++) {
			if (flag[i] == 1) {
				if (j++ > 0) printf(" ");
				printf("%d", i);
			}
		}
		printf("\n");
	}
	fflush(stdout);
	return 0;
}
0