結果

問題 No.2954 Calculation of Exponentiation
ユーザー syuya2036
提出日時 2024-11-09 02:54:26
言語 C++23
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 3 ms / 2,000 ms
コード長 929 bytes
コンパイル時間 3,350 ms
コンパイル使用メモリ 248,304 KB
実行使用メモリ 5,248 KB
最終ジャッジ日時 2024-11-09 02:54:32
合計ジャッジ時間 4,561 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 28
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
const long long INF = 1e18;

vector<pair<long, int>> prime_fact(long N) {
    vector<pair<long, int>> primes;
    int n = N;
    for(long i=2; i*i<=N+100; i++) {
        if (i != 2 && i != 5 && n % i != 0) continue;
        int cnt = 0;
        while(n % i == 0) {
            cnt++;
            n /= i;
        }
        if(i==2||i==5) cnt-=4;
        primes.push_back(make_pair(i, cnt));

    }

    if (n != 1) primes.push_back(make_pair(n, 1));
    return primes;
}

double A, B;
int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cin>>A>>B;
    long a = A * 10000;
    long b = B * 10000;

    vector<pair<long, int>> ps = prime_fact(a);

    bool ok = true;
    for(auto e:ps) {
        long ei = e.second;
        long eb = b * ei;
        if(!(eb >= 0 && eb % 10000 == 0)) {
            ok = false;
        }
    }
    cout<<(ok ? "Yes" : "No")<<endl;
}

0