結果
| 問題 | No.36 素数が嫌い! |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2026-07-30 04:52:53 |
| 言語 | C++23(gcc16) (gcc 16.1.0 + boost 1.90.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 686 bytes |
| 記録 | |
| コンパイル時間 | 2,388 ms |
| コンパイル使用メモリ | 176,072 KB |
| 実行使用メモリ | 46,840 KB |
| 最終ジャッジ日時 | 2026-07-30 04:53:03 |
| 合計ジャッジ時間 | 6,813 ms |
|
ジャッジサーバーID (参考情報) |
judge3_1 / judge2_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 22 WA * 4 |
ソースコード
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
using ll = long long;
int main(void){
ll n; cin >> n;
int nn=1e7+1;
vector<int> yakusu(nn+1, -1), prime;
for(int i=2; i<=nn; i++){
if(yakusu[i]!=-1) continue;
int copy=i;
prime.push_back(i);
while(copy<=nn){
if(yakusu[copy]==-1) yakusu[copy]=i;
copy+=i;
}
}
auto judge=[&](ll x){
for(auto p:prime){
if(x%p==0) return false;
}
return true;
};
if(n==1||judge(n)){
cout << "NO" << endl; return 0;
}
for(auto p:prime){
if(p>n) break;
if(n%p) continue;
cout << (judge(n/p)?"NO":"YES") << endl;
return 0;
}
return 0;
}