結果
問題 | No.312 置換処理 |
ユーザー | Nekosyndrome |
提出日時 | 2015-12-11 22:03:28 |
言語 | C++11 (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 13 ms / 2,000 ms |
コード長 | 964 bytes |
コンパイル時間 | 1,385 ms |
コンパイル使用メモリ | 160,644 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-11-15 11:58:43 |
合計ジャッジ時間 | 2,820 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 45 |
ソースコード
#include<bits/stdc++.h> #define REP(x,y,z) for(int x=y;x<=z;x++) #define FORD(x,y,z) for(int x=y;x>=z;x--) #define MSET(x,y) memset(x,y,sizeof(x)) #define FOR(x,y) for(__typeof(y.begin()) x=y.begin();x!=y.end();x++) #define F first #define S second #define MP make_pair #define PB push_back #define SZ size() #define M void RI(){} template<typename... T> void RI( int& head, T&... tail ) { scanf("%d",&head); RI(tail...); } using namespace std; typedef long long LL; LL n; vector<LL> fac; int main() { int cnt; while(~scanf("%lld",&n)) { fac.clear(); REP(i,2,1000000) { cnt=0; while(n%i==0) { n /= i; cnt++; } if(cnt==1) fac.PB(i); else if(cnt>=2) { fac.PB(i); fac.PB(i); } if(n==1) break; } if(n!=1) fac.PB(n); LL ans=fac[0]; if(ans==2) { if(fac[1]!=2) ans=fac[1]; else { ans=4; FOR(i,fac) if(*i!=2) ans = min(ans, *i); } } printf("%lld\n",ans); } return 0; }