結果

問題 No.3233 順列判定
ユーザー t98slider
提出日時 2025-08-15 21:33:49
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 17 ms / 1,000 ms
コード長 603 bytes
コンパイル時間 1,868 ms
コンパイル使用メモリ 196,412 KB
実行使用メモリ 7,716 KB
最終ジャッジ日時 2025-08-15 21:33:57
合計ジャッジ時間 3,134 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 40
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
using ll = long long;

long long intpow(long long a, long long b, int m){ 
    long long ans = 1; 
    while(b){ 
        if(b & 1) (ans *= a) %= m; 
        (a *= a) %= m; 
        b >>= 1; 
    } 
    return ans;
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, m;
    cin >> n >> m;
    vector<bool> used(n);
    used[0] = true;
    for(int i = 1; i < n; i++){
        int r = intpow(i, m, n);
        if(used[r]){
            cout << "No\n";
            return 0;
        }
        used[r] = true;
    }
    cout << "Yes\n";
}
0