結果
問題 |
No.2954 Calculation of Exponentiation
|
ユーザー |
|
提出日時 | 2024-11-08 22:44:43 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 573 bytes |
コンパイル時間 | 1,906 ms |
コンパイル使用メモリ | 165,748 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-11-08 22:44:49 |
合計ジャッジ時間 | 2,659 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 17 WA * 11 |
ソースコード
#include<bits/stdc++.h> #include <cmath> using namespace std; int gcd(int n1, int n2) { int ret = n1 % n2; return (ret == 0) ? n2 : gcd(n2, ret); } double A, B; int main() { cin>>A>>B; if(B>=0) { double p = 10000/gcd((int)B*10000, 10000); int r = round(pow(A, 1.0 / p)); if(A == pow(r, p)) cout<<"Yes"<<endl; else cout<<"No"<<endl; } else { double p = 10000/gcd((int)B*10000, 10000); int r = round(pow(A, -1.0 / p)); if(A == pow(r, p)) cout<<"Yes"<<endl; else cout<<"No"<<endl; } }