結果
問題 | No.300 平方数 |
ユーザー |
|
提出日時 | 2024-11-23 16:36:21 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 13 ms / 1,000 ms |
コード長 | 1,481 bytes |
コンパイル時間 | 3,690 ms |
コンパイル使用メモリ | 232,268 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-11-23 16:36:28 |
合計ジャッジ時間 | 5,164 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 43 |
ソースコード
#include<bits/stdc++.h>#include <atcoder/all>#ifdef LOCAL#include <debug_print.hpp>#define debug(...) debug_print::multi_print(#__VA_ARGS__, __VA_ARGS__)#else#define debug(...) (static_cast<void>(0))#endifusing namespace atcoder;using mint=modint998244353;using namespace std;using ll=long long;using ul=unsigned long long;int dx[8] = {-1, 1, 0, 0, -1, -1, 1, 1};int dy[8] = {0, 0, -1, 1, -1, 1, -1, 1};using Graph=vector<vector<int>>;ll op(ll a,ll b){return min(a,b);}ll e(){return 2e9;}vector<pair<long long, long long> > prime_factorize(long long N) {// 答えを表す可変長配列vector<pair<long long, long long> > res;// √N まで試し割っていくfor (long long p = 2; p * p <= N; ++p) {// N が p で割り切れないならばスキップif (N % p != 0) {continue;}// N の素因数 p に対する指数を求めるint e = 0;while (N % p == 0) {// 指数を 1 増やす++e;// N を p で割るN /= p;}// 答えに追加res.emplace_back(p, e);}// 素数が最後に残ることがありうるif (N != 1) {res.emplace_back(N, 1);}return res;}int main(){ll N;cin>>N;vector<pair<ll,ll>>P=prime_factorize(N);ll ans=1;for(int i=0;i<P.size();i++){if(P[i].second%2!=0)ans*=P[i].first;}cout<<ans<<endl;}