結果
問題 |
No.36 素数が嫌い!
|
ユーザー |
![]() |
提出日時 | 2014-10-08 01:18:43 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 835 bytes |
コンパイル時間 | 1,801 ms |
コンパイル使用メモリ | 157,416 KB |
実行使用メモリ | 13,312 KB |
最終ジャッジ日時 | 2024-12-30 08:13:46 |
合計ジャッジ時間 | 4,246 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 WA * 2 |
other | AC * 13 WA * 13 |
ソースコード
#include <bits/stdc++.h> using namespace std; #define MAX 10000010 bool prime[MAX]; typedef unsigned long long ull; void sieve() { fill(prime, prime+MAX, true); prime[0] = prime[1] = false; for(ull i=2 ; i*i<MAX ; i++){ if(prime[i]){ for(ull j=i*i ; j<MAX ; j+=i){ prime[j] = false; } } } } bool isPrime(ull a) { for(ull i=2; i*i <=a; i++) if(a%i == 0) return false; return true; } int main() { sieve(); ull N; cin >> N; if(N == 1) { cout << "NO\n"; return 0; } if(isPrime(N)) { cout << "NO\n"; return 0; } /* int cnt = 0; ull K = N; for(ull i=2; i*i<=K; i++) { if(prime[i]) { while(N % i == 0) { N /= i; cnt ++; } } } if(cnt >= 2) cout << "YES\n"; */ else cout << "NO\n"; return 0; }