結果
問題 | No.300 平方数 |
ユーザー | 保登心愛 |
提出日時 | 2015-11-13 23:54:41 |
言語 | C++11 (gcc 13.3.0) |
結果 |
WA
(最新)
AC
(最初)
|
実行時間 | - |
コード長 | 887 bytes |
コンパイル時間 | 697 ms |
コンパイル使用メモリ | 79,360 KB |
実行使用メモリ | 6,944 KB |
最終ジャッジ日時 | 2024-09-13 15:46:07 |
合計ジャッジ時間 | 1,964 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 27 WA * 16 |
ソースコード
#include <iostream> #include <cstdio> #include <cstring> #include <vector> #include <algorithm> #include <cmath> #include <map> using namespace std; typedef long long ll; #define SORT(x) sort((x).begin(), (x).end()) #define RSORT(x) sort((x).begin(), (x).end(), greater<int>() ) vector<int> primeFactorization(ll n) { vector<int> p; ll a = 2; while (n >= a * a) { if (n % a == 0) { p.push_back(a); n /= a; } else { a++; } } p.push_back(n); return p; } int main() { ll x, y = 1; cin >> x; vector<int> p = primeFactorization(x); map<int, int> m; for (int i = 0; i < p.size(); i++) { m[p[i]]++; } for (map<int, int>::iterator it = m.begin(); it != m.end(); ++it) { if ((*it).second % 2 == 1) y *= (*it).first; } cout << y << endl; return 0; }