結果

問題 No.1409 Simple Math in yukicoder
ユーザー pockynypockyny
提出日時 2021-02-26 23:47:06
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 945 bytes
コンパイル時間 856 ms
コンパイル使用メモリ 83,992 KB
実行使用メモリ 13,440 KB
最終ジャッジ日時 2024-04-10 14:48:24
合計ジャッジ時間 31,471 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 50 ms
13,184 KB
testcase_01 AC 50 ms
13,312 KB
testcase_02 AC 50 ms
13,184 KB
testcase_03 AC 49 ms
13,312 KB
testcase_04 AC 55 ms
13,312 KB
testcase_05 WA -
testcase_06 AC 49 ms
13,440 KB
testcase_07 AC 62 ms
13,312 KB
testcase_08 AC 89 ms
13,312 KB
testcase_09 AC 62 ms
13,312 KB
testcase_10 WA -
testcase_11 AC 84 ms
13,312 KB
testcase_12 WA -
testcase_13 AC 63 ms
13,312 KB
testcase_14 AC 59 ms
13,312 KB
testcase_15 AC 67 ms
13,312 KB
testcase_16 AC 65 ms
13,408 KB
testcase_17 AC 99 ms
13,184 KB
testcase_18 AC 71 ms
13,312 KB
testcase_19 WA -
testcase_20 AC 70 ms
13,312 KB
testcase_21 AC 69 ms
13,312 KB
testcase_22 AC 84 ms
13,312 KB
testcase_23 AC 60 ms
13,184 KB
testcase_24 AC 54 ms
13,184 KB
testcase_25 WA -
testcase_26 AC 81 ms
13,312 KB
testcase_27 AC 102 ms
13,312 KB
testcase_28 AC 104 ms
13,184 KB
testcase_29 AC 97 ms
13,312 KB
testcase_30 AC 103 ms
13,312 KB
testcase_31 AC 105 ms
13,312 KB
testcase_32 AC 100 ms
13,156 KB
testcase_33 AC 102 ms
13,312 KB
testcase_34 AC 101 ms
13,312 KB
testcase_35 AC 104 ms
13,440 KB
testcase_36 AC 100 ms
13,312 KB
testcase_37 AC 147 ms
13,440 KB
testcase_38 AC 147 ms
13,312 KB
testcase_39 AC 148 ms
13,184 KB
testcase_40 AC 147 ms
13,312 KB
testcase_41 AC 146 ms
13,288 KB
testcase_42 WA -
testcase_43 AC 147 ms
13,312 KB
testcase_44 AC 146 ms
13,184 KB
testcase_45 AC 147 ms
13,312 KB
testcase_46 AC 152 ms
13,184 KB
testcase_47 AC 152 ms
13,184 KB
testcase_48 AC 144 ms
13,312 KB
testcase_49 AC 150 ms
13,312 KB
testcase_50 AC 152 ms
13,312 KB
testcase_51 AC 150 ms
13,312 KB
testcase_52 AC 147 ms
13,312 KB
testcase_53 AC 149 ms
13,440 KB
testcase_54 AC 161 ms
13,312 KB
testcase_55 AC 148 ms
13,312 KB
testcase_56 AC 151 ms
13,184 KB
testcase_57 AC 185 ms
13,312 KB
testcase_58 AC 175 ms
13,312 KB
testcase_59 AC 180 ms
13,312 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
typedef long long ll;
ll pw(ll a,ll x,ll mod){
    ll ret = 1;
    while(x){
        if(x&1) (ret *= a) %= mod;
        (a *= a) %= mod; x /= 2;
    }
    return ret;
}

vector<int> di[100010] = {};
int main(){
    int t; cin >> t;
    for(int i=2;i<=100000;i++){
        for(int j=2*i;j<=100000;j+=i){
            di[j].push_back(i);
        }
    }
    while(t){
        t--;
        int i,j,x,v; cin >> v >> x;
        int r = -1,p = x*v + 1;
        for(i=2;i<=x*v;i++){
            bool f = true;
            for(int num: di[p - 1]){
                if(pw(i,num,p)==1) f = false;
            }
            if(f){
                r = i; break;
            }
        }
        vector<int> ans;
        for(i=1;i<=x;i++) ans.push_back(pw(r,i*v,p));
        sort(ans.begin(),ans.end());
        for(i=0;i<x;i++) cout << ans[i] << " ";
        cout << endl;
    }
}
0