結果
問題 | No.442 和と積 |
ユーザー |
![]() |
提出日時 | 2016-11-25 15:46:40 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 791 bytes |
コンパイル時間 | 1,793 ms |
コンパイル使用メモリ | 177,432 KB |
実行使用メモリ | 13,764 KB |
最終ジャッジ日時 | 2024-11-27 11:15:30 |
合計ジャッジ時間 | 4,793 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 WA * 1 |
other | AC * 4 WA * 13 TLE * 1 |
ソースコード
#include <bits/stdc++.h>using namespace std;std::map<unsigned long long, unsigned> prime_factorize(unsigned long long x) {std::map<unsigned long long, unsigned> ret;for (unsigned i = 2; 1ULL * i * i <= x; i++) {while (x % i == 0) x /= i, ret[i]++;}if (x != 1) ret[x]++;return ret;}long long A, B;int main() {cin >> A >> B;map<unsigned long long, unsigned> r1 = prime_factorize(A + B);map<unsigned long long, unsigned> r2 = prime_factorize(A);map<unsigned long long, unsigned> r3 = prime_factorize(B);for(pair<unsigned long long, unsigned> i : r3) r2[i.first] += i.second;long long ret = 1;for(pair<unsigned long long, unsigned> i : r2) {int x = min(i.second, r1[i.second]);for(int j = 0; j < x; j++) ret *= i.first;}cout << ret << endl;return 0;}