結果

問題 No.3115 One Power One Kill
ユーザー GOTKAKO
提出日時 2025-04-18 21:07:25
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 65 ms / 2,000 ms
コード長 2,544 bytes
コンパイル時間 2,060 ms
コンパイル使用メモリ 191,780 KB
実行使用メモリ 25,996 KB
平均クエリ数 2.00
最終ジャッジ日時 2025-04-18 21:07:38
合計ジャッジ時間 4,645 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 20
権限があれば一括ダウンロードができます

ソースコード

diff #

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

long long mod = 1e9+7;
//入力が必ず-mod<a<modの時.
struct mint{
    long long v = 0;
    mint(){} mint(int a){v = a<0?a+mod:a;} mint(long long a){v = a<0?a+mod:a;}
    mint(unsigned long long a){v = a;}
    long long val(){return v;}

    mint &operator=(const mint &b) = default;
    mint operator-() const {return mint(0)-(*this);}
    mint operator+(const mint b){return mint(v)+=b;}
    mint operator-(const mint b){return mint(v)-=b;}
    mint operator*(const mint b){return mint(v)*=b;}
    mint operator/(const mint b){return mint(v)/=b;}

    mint operator+=(const mint b){
        v += b.v; if(v >= mod) v -= mod;
        return *this;
    }
    mint operator-=(const mint b){
        v -= b.v; if(v < 0) v += mod; 
        return *this;
    }   
    mint operator*=(const mint b){v = v*b.v%mod; return *this;}
    mint operator/=(mint b){
        if(b == 0) assert(false);
        int left = mod-2;
        while(left){if(left&1) *this *= b; b *= b; left >>= 1;}
        return *this;
    }

    mint operator++(){*this += 1; return *this;}
    mint operator--(){*this -= 1; return *this;}
    mint operator++(int){*this += 1; return *this;}
    mint operator--(int){*this -= 1; return *this;}
    bool operator==(const mint b){return v == b.v;}
    bool operator!=(const mint b){return v != b.v;}
    bool operator>(const mint b){return v > b.v;}
    bool operator>=(const mint b){return v >= b.v;}
    bool operator<(const mint b){return v < b.v;}
    bool operator<=(const mint b){return v <= b.v;}

    mint pow(long long n){
        mint ret = 1,p = v;
        if(n < 0) p = p.inv(),n = -n;
        while(n){
            if(n&1) ret *= p;
            p *= p; n >>= 1;
        }
        return ret;
    }
    mint inv(){return mint(1)/v;}
};

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

    cout << 19000 << " " << 101 << endl;
    int K; cin >> K;
    if(K%101 == 0) cout << 0 << endl;
    else cout << 1 << endl;
    return 0;

    int Need = 100000;
    vector<bool> prime(Need+1,true);
    prime.at(0) = false; prime.at(1) = false;
    for(int i=2; i*i<=Need; i++){
        if(!prime.at(i)) continue;
        for(int k=i*i; k<=Need; k+=i) prime.at(k) = false;
    }
    for(int B=101; B<=100000; B++){
        if(prime.at(B) == false) continue;
        for(int A=B-1; A<=100000; A+=B-1){
            mint Y = mint(A).pow(B);
            if(Y.v%B == 0){cout << A << " " << B << endl; return 0;} 
        }   
    }
    cout << "END" << endl;
}
0