結果
問題 | No.36 素数が嫌い! |
ユーザー |
![]() |
提出日時 | 2017-11-29 21:46:01 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 108 ms / 5,000 ms |
コード長 | 778 bytes |
コンパイル時間 | 498 ms |
コンパイル使用メモリ | 58,956 KB |
実行使用メモリ | 12,800 KB |
最終ジャッジ日時 | 2024-06-27 01:16:33 |
合計ジャッジ時間 | 2,199 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 26 |
ソースコード
#include <iostream> #include <math.h> using namespace std; #define fastcin {\ cin.tie(0);\ ios::sync_with_stdio(false);\ } #define rep(i, a, b) for(int i = a; i < b; ++i) #define scan(x) cin >> x #define print(x) cout << x << "\n" int main() { fastcin; long N; scan(N); auto sq = (int)sqrt(N); bool flag = false, p[sq+1]; int k; rep(i, 2, sq+1) p[i] = true; rep(i, 2, sq+1) { if (p[i]) { k = i; while (k!=N && !(N%k)) { if (flag) { print("YES"); return 0; } flag = true; k *= k; } for (int j = i<<1; j < sq+1; j+=i) p[j] = false; } } print("NO"); return 0; }