結果
問題 |
No.36 素数が嫌い!
|
ユーザー |
|
提出日時 | 2018-05-15 20:50:45 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 114 ms / 5,000 ms |
コード長 | 551 bytes |
コンパイル時間 | 544 ms |
コンパイル使用メモリ | 68,204 KB |
実行使用メモリ | 6,944 KB |
最終ジャッジ日時 | 2024-06-28 12:10:56 |
合計ジャッジ時間 | 1,854 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 26 |
ソースコード
#include<iostream> #include<cmath> using namespace std; typedef long long ll; bool isPrime(ll a){ for(ll i = 2; i <= sqrt(a); i++){ if(a%i == 0) return false; } return true; } int main(){ ll n; cin >> n; for(ll i = 2; i <= sqrt(n); i++){ if(n % i == 0){ if(!isPrime(i) || !isPrime(n/i)){ cout << "YES" << endl; return 0; } while(n%i == 0){ n /= i; } } } cout << "NO" << endl; return 0; }