結果
問題 |
No.312 置換処理
|
ユーザー |
![]() |
提出日時 | 2015-12-17 04:57:21 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 682 bytes |
コンパイル時間 | 629 ms |
コンパイル使用メモリ | 76,308 KB |
実行使用メモリ | 11,136 KB |
最終ジャッジ日時 | 2024-09-16 07:05:59 |
合計ジャッジ時間 | 2,872 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 29 WA * 16 |
ソースコード
#include<iostream> #include<algorithm> #include<vector> #include<cmath> #include<memory> using namespace std; using Long=long long int; std::vector<Long> genprimes(Long N) { std::vector<Long> p(N); for(Long i=2;i<N;++i) p[i]=i; for(Long i=2;i<sqrt(N);++i) { if(p[i]) { for(Long j=2*i;j<N;j+=i) { p[j]=0; } } } p.erase(remove(p.begin(),p.end(),0),p.end()); return p; } int main() { auto primes = genprimes(Long(1e6)); Long N;cin>>N; for(auto x : primes) { if(x==2) continue; if(N%x==0) { cout<<x<<endl; return 0; } } cout<<N<<endl; }