結果
| 問題 |
No.2954 Calculation of Exponentiation
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2024-11-08 22:36:07 |
| 言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 973 bytes |
| コンパイル時間 | 2,895 ms |
| コンパイル使用メモリ | 245,532 KB |
| 実行使用メモリ | 5,248 KB |
| 最終ジャッジ日時 | 2024-11-08 22:36:11 |
| 合計ジャッジ時間 | 3,780 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 23 WA * 5 |
ソースコード
#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(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 = 0; i <= 10000; i++) {
if(i * decimal % 10000 == 0) {
// 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;
}