結果

問題 No.3233 順列判定
ユーザー ジュ・ビオレ・グレイス
提出日時 2025-08-15 23:12:02
言語 D
(dmd 2.109.1)
結果
WA  
実行時間 -
コード長 550 bytes
コンパイル時間 928 ms
コンパイル使用メモリ 87,116 KB
実行使用メモリ 8,072 KB
最終ジャッジ日時 2025-08-15 23:12:09
合計ジャッジ時間 3,499 ms
ジャッジサーバーID
(参考情報)
judge6 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 35 WA * 5
権限があれば一括ダウンロードができます

ソースコード

diff #

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

void main() {
	auto tmp = readln.split.to!(uint[]);
	auto N = tmp[0], M = tmp[1];
	
	bool[uint] Aset;
	auto A = new uint[N];
	foreach (i; 1 .. N+1) {
		auto m = pow_mod(i, M, N);
		Aset[m] = true;
		A[m] += 1;
	}
	
	//writeln(Aset.keys.sort.equal(iota(N)) ? "Yes" : "No");
	writeln(A.all!"a==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