結果

問題 No.1140 EXPotentiaLLL!
ユーザー yuji9511yuji9511
提出日時 2020-07-31 22:11:58
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 919 ms / 2,000 ms
コード長 1,471 bytes
コンパイル時間 2,260 ms
コンパイル使用メモリ 210,052 KB
実行使用メモリ 43,432 KB
最終ジャッジ日時 2023-09-20 23:42:08
合計ジャッジ時間 10,490 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 429 ms
22,228 KB
testcase_01 AC 429 ms
22,388 KB
testcase_02 AC 435 ms
22,040 KB
testcase_03 AC 747 ms
39,916 KB
testcase_04 AC 612 ms
35,168 KB
testcase_05 AC 919 ms
43,432 KB
testcase_06 AC 884 ms
42,276 KB
testcase_07 AC 747 ms
22,380 KB
testcase_08 AC 159 ms
22,172 KB
testcase_09 AC 159 ms
23,420 KB
testcase_10 AC 159 ms
22,100 KB
testcase_11 AC 159 ms
22,460 KB
testcase_12 AC 158 ms
22,620 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: 関数 ‘std::vector<long long int> sieve(ll)’ 内:
main.cpp:26:15: 警告: 左シフト回数 >= 型の幅となっています [-Wshift-count-overflow]
   26 |     rep(i,0,(1<<60)){
      |              ~^~~~
main.cpp:8:36: 備考: in definition of macro ‘rep’
    8 | #define rep(i,m,n) for(ll i=(m);i<(n);i++)
      |                                    ^

ソースコード

diff #

/*** author: yuji9511 ***/
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using lpair = pair<ll, ll>;
const ll MOD = 1e9+7;
const ll INF = 1e18;
#define rep(i,m,n) for(ll i=(m);i<(n);i++)
#define rrep(i,m,n) for(ll i=(m);i>=(n);i--)
#define printa(x,n) for(ll i=0;i<n;i++){cout<<(x[i])<<" \n"[i==n-1];};
void print() {}
template <class H,class... T>
void print(H&& h, T&&... t){cout<<h<<" \n"[sizeof...(t)==0];print(forward<T>(t)...);}
vector<ll> sieve(ll n){ //エラトステネス
    vector<bool> is_prime(n+1);
    vector<ll> prime;
    rep(i,0,n+1) is_prime[i] = true;
    is_prime[0] = is_prime[1] = false;
    rep(i,2,n+1){
        if(is_prime[i]){
            prime.push_back(i);
            for(int j = 2 * i; j <= n; j += i) is_prime[j] = false;
        }
    }
    return prime;
    rep(i,0,(1<<60)){
        print(i);
    }
}
ll power(ll x, ll n, ll M){
    if(n == 0) return 1LL;
    ll res = power(x * x % M, n/2, M);
    if(n % 2 == 1) res = res * x % M;
    return res;
}
vector<ll> primes = sieve(5000000);

void solve(){
    map<int,bool> mp;
    for(auto &e: primes) mp[e] = true;
    ll T;
    cin >> T;
    while(T--){
        ll A,P;
        cin >> A >> P;
        if(not mp[P]){
            print(-1);
        }else{
            if(A % P == 0){
                print(0);
            }else{
                print(1);
            }
        }
    }


}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    solve();
}
0