結果

問題 No.3233 順列判定
ユーザー eve__fuyuki
提出日時 2025-08-21 23:22:16
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 591 bytes
コンパイル時間 1,952 ms
コンパイル使用メモリ 201,004 KB
実行使用メモリ 7,720 KB
最終ジャッジ日時 2025-08-21 23:22:20
合計ジャッジ時間 3,823 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 35 WA * 5
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

using namespace std;

void fast_io() {
	ios::sync_with_stdio(false);
	std::cin.tie(nullptr);
}

long long pow_mod(int base, int exp, int mod) {
	long long res = 1;
	while (exp > 0) {
		if (exp % 2 == 1) {
			res = (res * base) % mod;
		}
		base = (base * base) % mod;
		exp /= 2;
	}
	return res;
}

int main() {
	fast_io();
	int n, m;
	cin >> n >> m;
	vector<long long> a;
	for (int i = 1; i <= n; i++) {
		a.push_back(pow_mod(i, m, n));
	}
	sort(a.begin(), a.end());
	a.erase(unique(a.begin(), a.end()), a.end());
	cout << (a.size() == n ? "Yes" : "No") << endl;
}
0