結果

問題 No.1728 [Cherry 3rd Tune] Bullet
ユーザー chocoruskchocorusk
提出日時 2021-09-13 21:45:38
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 54 ms / 2,000 ms
コード長 1,600 bytes
コンパイル時間 8,961 ms
コンパイル使用メモリ 289,740 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-08-24 13:09:06
合計ジャッジ時間 10,738 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 1 ms
4,384 KB
testcase_04 AC 2 ms
4,380 KB
testcase_05 AC 1 ms
4,380 KB
testcase_06 AC 1 ms
4,380 KB
testcase_07 AC 2 ms
4,376 KB
testcase_08 AC 2 ms
4,376 KB
testcase_09 AC 2 ms
4,380 KB
testcase_10 AC 3 ms
4,376 KB
testcase_11 AC 2 ms
4,380 KB
testcase_12 AC 2 ms
4,380 KB
testcase_13 AC 2 ms
4,380 KB
testcase_14 AC 2 ms
4,380 KB
testcase_15 AC 3 ms
4,376 KB
testcase_16 AC 3 ms
4,380 KB
testcase_17 AC 2 ms
4,380 KB
testcase_18 AC 2 ms
4,380 KB
testcase_19 AC 3 ms
4,380 KB
testcase_20 AC 2 ms
4,376 KB
testcase_21 AC 2 ms
4,376 KB
testcase_22 AC 2 ms
4,376 KB
testcase_23 AC 54 ms
4,376 KB
testcase_24 AC 35 ms
4,376 KB
testcase_25 AC 3 ms
4,376 KB
testcase_26 AC 2 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include "testlib.h"
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
#include <fstream>
#include <utility>
#include <functional>
#include <time.h>
#include <stack>
#include <array>
#include <list>
#include <atcoder/all>
#define popcount __builtin_popcount
using namespace std;
using namespace atcoder;
typedef long long ll;
typedef pair<int, int> P;
using mint=modint1000000007;
const int MAXT=10;
const int MAXN=1000000000;
const int MAXC=1000000000;
int main(int argc, char* argv[]){
    registerValidation(argc, argv);
    int t=inf.readInt(1, MAXT);
    inf.readEoln();
    while(t--){
        int n=inf.readInt(3, MAXN);
        inf.readSpace();
        int c=inf.readInt(1, MAXC);
        inf.readEoln();

        vector<int> vd;
        for(int i=1; i*i<=n; i++){
            if(n%i==0){
                vd.push_back(i);
                if(i*i<n) vd.push_back(n/i);
            }
        }
        sort(vd.begin(), vd.end());
        int m=vd.size();
        vector<int> vc(m);
        mint ans=mint(c).pow(n)*n;
        for(int i=m-1; i>=0; i--){
            vc[i]=n/vd[i];
            for(int j=i+1; j<m; j++){
                if(vd[j]%vd[i]==0) vc[i]-=vc[j];
            }
            ans+=mint(c).pow(2*vd[i])*vc[i];
        }
        ans/=(2*n);
        cout<<ans.val()<<endl;
    }
    inf.readEof();
    return 0;
}
0