結果
問題 | No.1556 Power Equality |
ユーザー |
![]() |
提出日時 | 2021-06-25 22:44:09 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 2 ms / 2,000 ms |
コード長 | 855 bytes |
コンパイル時間 | 457 ms |
コンパイル使用メモリ | 56,112 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-06-25 09:48:55 |
合計ジャッジ時間 | 949 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 9 |
ソースコード
#include <cstdio> #include <vector> #include <algorithm> struct Element { long long u; long long cnt; }; std::vector<Element> getFactor(long long n){ std::vector<Element> res; for(long long i = 2; i*i <= n; i++){ if(n == 1) break; if(n%i==0){ int cnt = 0; while(n%i==0){ n /= i; cnt++; } res.push_back({i, cnt}); } } if(n!=1) res.push_back({n, 1}); std::sort(res.begin(), res.end(), [](Element& u, Element& v){ return u.u < v.u; }); return res; } int main(){ long long a,b; scanf("%lld%lld",&a,&b); std::vector<Element> fa = getFactor(a); std::vector<Element> fb = getFactor(b); int ok = 1; if(fa.size()!=fb.size()) ok = 0; for(int i = 0; i < (int)fa.size(); i++){ if(fa[i].u!=fb[i].u) ok = 0; if(fa[i].cnt*b!=fb[i].cnt*a) ok = 0; } if(ok) printf("Yes\n"); else printf("No\n"); return 0; }