結果
問題 |
No.36 素数が嫌い!
|
ユーザー |
![]() |
提出日時 | 2016-08-09 14:27:50 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
RE
|
実行時間 | - |
コード長 | 730 bytes |
コンパイル時間 | 1,672 ms |
コンパイル使用メモリ | 164,100 KB |
実行使用メモリ | 108,420 KB |
最終ジャッジ日時 | 2024-11-07 08:14:59 |
合計ジャッジ時間 | 8,673 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | -- * 4 |
other | AC * 2 WA * 1 RE * 2 TLE * 1 -- * 20 |
ソースコード
#include<bits/stdc++.h> using namespace std; int main(){ long long n; cin >> n; vector<long long> primes; vector<bool> isPrime(n, true); isPrime[0] = false; isPrime[1] = false; for(long long i = 2; i <= n; i++){ if(isPrime[i] == true){ primes.push_back(i); for(long long j = i * 2; j <= n; j += i){ isPrime[j] = false; } } } long long j = 0; bool ok = false; for(long long i = 1; i < n; i++){ if(i == 1){ continue; }else if(i == primes[j]){ j++; continue; }else{ if(n % i == 0){ ok = true; break; } } cout << i << " " << ok << endl; } if(ok == true)cout << "YES" << endl; else cout << "NO" << endl; }