結果
問題 |
No.300 平方数
|
ユーザー |
|
提出日時 | 2020-01-16 19:46:38 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 13 ms / 1,000 ms |
コード長 | 904 bytes |
コンパイル時間 | 1,981 ms |
コンパイル使用メモリ | 170,004 KB |
実行使用メモリ | 6,944 KB |
最終ジャッジ日時 | 2024-06-24 01:42:46 |
合計ジャッジ時間 | 3,530 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 43 |
ソースコード
#include <bits/stdc++.h> using namespace std; #define rep(i, n) for(int i = 0; i < (int)n; ++i) #define FOR(i, a, b) for(int i = a; i < (int)b; ++i) #define rrep(i, n) for(int i = ((int)n - 1); i >= 0; --i) typedef long long ll; typedef long double ld; const int Inf = 1e9; const double EPS = 1e-9; const int MOD = 1e9 + 7; vector<pair<ll, int> > prime_factorize(ll n) { vector<pair<ll, int> > res; for (ll i = 2; i * i <= n; ++i) { if (n % i) continue; res.push_back(make_pair(i, 0)); while (n % i == 0) { n /= i; res.back().second++; } } if (n != 1) res.push_back(make_pair(n, 1)); return res; } int main() { cin.tie(nullptr); ios::sync_with_stdio(0); ll x; cin >> x; ll res = 1; auto v = prime_factorize(x); rep (i, v.size()) { if (v[i].second % 2) res *= v[i].first; } cout << res << endl; return 0; }