結果

問題 No.3233 順列判定
ユーザー ジュ・ビオレ・グレイス
提出日時 2025-08-15 22:44:32
言語 D
(dmd 2.109.1)
結果
WA  
実行時間 -
コード長 433 bytes
コンパイル時間 639 ms
コンパイル使用メモリ 86,320 KB
実行使用メモリ 8,076 KB
最終ジャッジ日時 2025-08-15 22:46:30
合計ジャッジ時間 3,162 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 34 WA * 6
権限があれば一括ダウンロードができます

ソースコード

diff #

import std.stdio, std.algorithm, std.array, std.conv, std.typecons;

void main() {
	auto tmp = readln.split.to!(uint[]);
	auto N = tmp[0], M = tmp[1];
	
	bool[uint] Aset;
	foreach (i; 1 .. N) {
		Aset[pow_mod(i, M, N)] = true;
	}
	writeln(Aset.length == N-1 ? "Yes" : "No");
}

// (i ^^ p) % n for i > 0
uint pow_mod(uint i, uint p, uint n) {
	uint result = 1;
	foreach (_; 0 .. p) {
		result = (result * i) % n;
	}
	return result;
}
0