結果
問題 |
No.2954 Calculation of Exponentiation
|
ユーザー |
|
提出日時 | 2024-11-08 22:44:20 |
言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,081 bytes |
コンパイル時間 | 2,571 ms |
コンパイル使用メモリ | 245,668 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-11-08 22:44:36 |
合計ジャッジ時間 | 3,467 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 24 WA * 4 |
ソースコード
#include <bits/stdc++.h> using namespace std; long long pow(long long b, long long e) { long long ret = 1; while(e) { if(e & 1) ret *= b; b *= b; e >>= 1; } return ret; } int main() { string A, B; cin >> A >> B; if(B == "0.0000") { cout << "Yes\n"; return 0; } if(A.substr(A.size() - 4) != "0000") { cout << "No\n"; return 0; } if(B.substr(B.size() - 4) == "0000") { cout << "Yes\n"; return 0; } long long integer = stoi(A.substr(0, A.size() - 5)); long long decimal = stoi(B.substr(B.size() - 4)); for(long long i = 1; i <= 10000; i++) { if(i * decimal % 10000 == 0) { // cerr << i << "\n"; // A = j ^ iならよい for(long long j = 0; j <= integer; j++) { if(integer < pow(j, i)) break; if(integer == pow(j, i)) { cout << "Yes\n"; return 0; } } } } cout << "No\n"; return 0; }