結果

問題 No.2954 Calculation of Exponentiation
ユーザー FplusFplusFFplusFplusF
提出日時 2024-11-08 23:28:06
言語 C++23
(gcc 13.3.0 + boost 1.87.0)
結果
RE  
実行時間 -
コード長 2,376 bytes
コンパイル時間 3,215 ms
コンパイル使用メモリ 252,344 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-11-08 23:28:13
合計ジャッジ時間 5,858 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2 RE * 1
other AC * 15 WA * 4 RE * 9
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using ull=unsigned long long;
using pll=pair<ll,ll>;
using tll=tuple<ll,ll,ll>;
using ld=long double;
constexpr ll INF=(1ll<<60);
#define rep(i,n) for (ll i=0;i<(ll)(n);i++)
#define replr(i,l,r) for (ll i=(ll)(l);i<(ll)(r);i++)
#define all(v) v.begin(),v.end()
#define len(v) ((ll)v.size())
template<class T> inline bool chmin(T &a,T b){
    if(a>b){
        a=b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T &a,T b){
    if(a<b){
        a=b;
        return true;
    }
    return false;
}
template<class T> T binary_search(auto f,T ok,T ng){
    while(1<abs(ok-ng)){
        T mid=midpoint(ok,ng);
        if(f(mid)) ok=mid;
        else ng=mid;
    }
    return ok;
}
int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    string sa,sb;
    cin >> sa >> sb;

    ll ax=0,ay=0,bx=0,by=0;

    bool f=false;

    for(auto i:sa){
        if(i=='.'){
            f=true;
            continue;
        }
        if(!f){
            ax*=10;
            ax+=i-'0';
        }else{
            ay*=10;
            ay+=i-'0';
        }
    }

    f=false;

    ll z=1;

    for(auto i:sb){
        if(i=='-'){
            z=-1;
            continue;
        }
        if(i=='.'){
            f=true;
            continue;
        }
        if(!f){
            bx*=10;
            bx+=i-'0';
        }else{
            by*=10;
            by+=i-'0';
        }
    }
    if(bx==0&&by==0){
        cout << "Yes\n";
        return 0;
    }

    if(z==-1){
        assert(0);
    }else{
        ll a=ax*10000+ay;
        ll b=bx*10000+by;
        bool ok=true;
        ll p=10000/gcd(10000,b),q=b/gcd(10000,b);
        ll x=10000/gcd(10000,a);
        map<ll,ll> mp;
        for(ll i=2;i*i<=x;i++){
            ll cnt=0;
            while(x%i==0){
                x/=i;
                cnt++;
            }
            mp[i]=cnt;
        }

        x=a/gcd(10000,a);

        map<ll,ll> mp2;

        for(ll i=2;i*i<=x;i++){
            ll cnt=0;
            while(x%i==0){
                x/=i;
                cnt++;
            }
            if(cnt%p!=0) ok=false;
            mp2[i]=cnt;
        }

        for(auto [k,v]:mp){
            //if(!mp2.contains(k)||mp2[k]<v) ok=false;
        }


        if(ok) cout << "Yes\n";
        else cout << "No\n";
    }
}
0