結果

問題 No.3233 順列判定
ユーザー ジュ・ビオレ・グレイス
提出日時 2025-08-15 23:02:02
言語 D
(dmd 2.109.1)
結果
WA  
実行時間 -
コード長 693 bytes
コンパイル時間 1,489 ms
コンパイル使用メモリ 86,324 KB
実行使用メモリ 8,076 KB
最終ジャッジ日時 2025-08-15 23:02:06
合計ジャッジ時間 3,540 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
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 ans = true;
	
	bool[uint] Aset;
	foreach (i; 1 .. N+1) {
		auto m = pow_mod(i, M, N);
		if (m in Aset) ans = false;
		Aset[m] = true;
	}
	
	int count;
	if (Aset.length == N) {
		if (!ans) while (true) {count++;}
	}
	else {
		if (ans) while (true) {count++;}
	}
	//writeln(Aset.keys.sort.equal(iota(N)) ? "Yes" : "No");
	writeln(Aset.length >= N ? "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