結果
問題 |
No.300 平方数
|
ユーザー |
![]() |
提出日時 | 2016-10-31 12:49:09 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 10 ms / 1,000 ms |
コード長 | 606 bytes |
コンパイル時間 | 1,460 ms |
コンパイル使用メモリ | 175,176 KB |
実行使用メモリ | 6,820 KB |
最終ジャッジ日時 | 2024-11-25 00:02:48 |
合計ジャッジ時間 | 2,722 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 43 |
ソースコード
#include <bits/stdc++.h> using namespace std; // ------------ Prime Factorization (Update 8/6) ------------ // 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 x; int main() { cin >> x; map<unsigned long long, unsigned> res = prime_factorize(x); long long ret = 1; for(pair<unsigned long long, unsigned> i : res) { if(i.second & 1) ret *= i.first; } cout << ret << endl; return 0; }