結果

問題 No.3233 順列判定
ユーザー daiota
提出日時 2025-08-15 22:51:20
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 50 ms / 1,000 ms
コード長 557 bytes
コンパイル時間 1,377 ms
コンパイル使用メモリ 167,528 KB
実行使用メモリ 8,320 KB
最終ジャッジ日時 2025-08-15 22:51:28
合計ジャッジ時間 3,005 ms
ジャッジサーバーID
(参考情報)
judge1 / judge6
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 40
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef pair<ll,ll> P;
#define REP(i,n) for(ll i=0;i<ll(n);i++)






ll MOD;

ll f(ll x,ll n){
    ll res=1;
    while(n!=0LL){
	if(n%2!=0LL) res=(res*x)%MOD;
	x=(x*x)%MOD;
	n/=2;
   }
    return res;
}








int main(void){
	cin.tie(nullptr);  ios_base::sync_with_stdio(false);
	ll i,j;


	ll N,M;
	cin >> N >> M;

	MOD=N;

	set<ll> s;
	for(i=1;i<=N;i++){
		s.insert(f(i,M));
	}


	if((ll)s.size()==N) cout << "Yes" << endl;
	else cout << "No" << endl;











	return 0;

}





0