結果
問題 |
No.106 素数が嫌い!2
|
ユーザー |
|
提出日時 | 2016-03-15 19:06:14 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 654 bytes |
コンパイル時間 | 1,248 ms |
コンパイル使用メモリ | 157,688 KB |
実行使用メモリ | 11,264 KB |
最終ジャッジ日時 | 2024-10-01 06:37:48 |
合計ジャッジ時間 | 3,527 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 11 WA * 2 |
ソースコード
#include <bits/stdc++.h> using namespace std; int main() { int a[2000000] = {0},n,x,f; long long ans = 0; cin >> n >> x; for(int i = 2; i <= n; i += 2){ a[i - 2] = 1; } for(int i = 2; i <= n; i++){ if (a[i - 2] > 0) { if (a[i - 2] >= x) ans++; continue; } f = 0; for(int j = 3; j * j <= i; j += 2){ if (i % j == 0) { f = 1; break; } } if (f == 0) { for(int k = i; k <= n; k += i) { a[k - 2]++; } } } cout << ans << "\n"; return 0; }