結果

問題 No.3115 One Power One Kill
ユーザー Today03
提出日時 2025-04-19 01:39:27
言語 C++23
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 2,961 bytes
コンパイル時間 2,877 ms
コンパイル使用メモリ 279,736 KB
実行使用メモリ 26,252 KB
平均クエリ数 2.00
最終ジャッジ日時 2025-04-19 01:39:36
合計ジャッジ時間 7,544 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other WA * 20
権限があれば一括ダウンロードができます

ソースコード

diff #

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

#define ALL(x) (x).begin(),(x).end()
#define IO ios::sync_with_stdio(false),cin.tie(nullptr);
#define LB(v, x) (ll)(lower_bound(ALL(v),x)-(v).begin())
#define UQ(v) sort(ALL(v)),(v).erase(unique(ALL(v)),v.end())
#define REP(i, n) for(ll i=0; i<(ll)(n); i++)
#define FOR(i, a, b) for(ll i=(ll)(a); (a)<(b) ? i<(b) : i>(b); i+=((a)<(b) ? 1 : -1))
#define chmax(a, b) ((a)<(b) ? ((a)=(b), 1) : 0)
#define chmin(a, b) ((a)>(b) ? ((a)=(b), 1) : 0)

template<typename T> using rpriority_queue=priority_queue<T,vector<T>,greater<T>>;
using ll=long long; const int INF=1e9+10; const ll INFL=4e18; using ld=long double; using ull=uint64_t;
using VI=vector<int>; using VVI=vector<VI>; using VL=vector<ll>; using VVL=vector<VL>;
using PL=pair<ll,ll>; using VP=vector<PL>; using WG=vector<vector<pair<int,ll>>>;



/// @brief 疑似乱数生成
ull Xor128(){
    static bool flag=false;
    static ull x=123456789,y=362436069,z=521288629,w=88675123;
    if(!flag){
        random_device seedgen;
        w=seedgen();
        flag=true;
    }
    ull t=x^(x<<11);
    x=y,y=z,z=w;
    return w=(w^(w>>19))^(t^(t>>8));
}
ll Xor128(ll n){ return Xor128()%n; }
ll Xor128(ll l, ll r){ return Xor128(r-l)+l; }//[l,r)
double Xor128Prob(){ return (double)Xor128()/(1ULL<<32); }


/// @brief x^n (mod m) を返す
/// @note O(log(m))
template<typename T=ll>
T ModPow(T x, T n, T mod){
    ll ret=1;
    if(typeid(T)==typeid(ll)&&mod>INF*2) return ModPow<__int128_t>(x,n,mod);
    while(n>0){
        if(n&1) (ret*=x)%=mod;
        (x*=x)%=mod;
        n>>=1;
    }
    return ret;
}

/// @brief x^(-1) (mod m) を返す
ll ModInv(ll a, ll m){
    ll b=m,u=1,v=0;
    while(b){
        ll t=a/b;
        a-=t*b; swap(a,b);
        u-=t*v; swap(u,v);
    }
    return (u+m)%m;
}


/// @brief ミラーラビン素数判定法により n が素数であるかを判定する
/// @note O(k log^3 n)
/// @ref https://drken1215.hatenablog.com/entry/2023/05/23/233000
/// @ref verify: https://judge.yosupo.jp/problem/primality_test
bool PrimalityTest(ll n){
    if(n==2) return true;
    if(n<=1||n%2==0) return false;

    VL test;
    if(n<4759123141ll) test={2,7,61};
    else test={2,325,9375,28178,450775,9780504,1795265022};

    ll s=0,d=n-1;
    while(d%2==0) d>>=1,s++;

    for(ll a:test){
        if(a>=n) break;
        __int128_t x=ModPow<__int128_t>(a,d,n);

        if(x==1||x==n-1) continue;
        else{
            for(ll r=1; r<s; r++){
                x=x*x%n;
                if(x==1) return false;
                else if(x==n-1) break;
            }
        }
        if(x!=n-1)return false;
    }

    return true;
}

//----------------------------------------------------------

int main(){
    ll P=1e5;
    while(!PrimalityTest(P)) P--;

    ll A=P-1,B=P; cout<<A<<' '<<B<<endl;
    ll K; cin>>K;

    const ll mod=1e9+7;
    if(K==ModPow(A,B,mod)){
        cout<<0<<'\n';
    }else{
        cout<<1<<'\n';
    }
}
0