結果
| 問題 |
No.2954 Calculation of Exponentiation
|
| コンテスト | |
| ユーザー |
startcpp
|
| 提出日時 | 2024-11-08 22:04:10 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 11 ms / 2,000 ms |
| コード長 | 1,026 bytes |
| コンパイル時間 | 797 ms |
| コンパイル使用メモリ | 82,864 KB |
| 実行使用メモリ | 5,888 KB |
| 最終ジャッジ日時 | 2024-11-08 22:04:27 |
| 合計ジャッジ時間 | 1,694 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 28 |
ソースコード
//tan 1°は有理数か?を彷彿させますね
#include <iostream>
#include <vector>
#include <map>
#define int long long
#define rep(i, n) for(i = 0; i < n; i++)
using namespace std;
signed main() {
double A, B; cin >> A >> B;
int siA = (int)(10000 * A);
int boA = 10000;
int b = (int)(10000 * B);
vector<int> pa, ea, pa2, ea2;
int tmp = siA;
for (int i = 2; i * i <= tmp; i++) {
int cnt = 0;
while (tmp % i == 0) {
tmp /= i;
cnt++;
}
pa.push_back(i);
ea.push_back(cnt);
}
if (tmp > 1) {
pa.push_back(tmp);
ea.push_back(1);
}
pa2.push_back(2);
ea2.push_back(4);
pa2.push_back(5);
ea2.push_back(4);
map<int, int> mp;
for (int i = 0; i < pa.size(); i++) {
ea[i] *= b;
mp[pa[i]] += ea[i];
}
for (int i = 0; i < pa2.size(); i++) {
ea2[i] *= b;
mp[pa2[i]] -= ea2[i];
}
for (map<int, int>::iterator it = mp.begin(); it != mp.end(); it++) {
if (it->second < 0 || it->second % 10000 != 0) {
cout << "No" << endl;
return 0;
}
}
cout << "Yes" << endl;
return 0;
}
startcpp