結果
問題 | No.1657 Sum is Prime (Easy Version) |
ユーザー |
|
提出日時 | 2021-08-27 21:25:25 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 32 ms / 2,000 ms |
コード長 | 596 bytes |
コンパイル時間 | 2,390 ms |
コンパイル使用メモリ | 192,836 KB |
最終ジャッジ日時 | 2025-01-24 02:27:58 |
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 21 |
ソースコード
#include <bits/stdc++.h> using namespace std; int main(){ ios::sync_with_stdio(false); cin.tie(nullptr); int L, R; cin >> L >> R; vector<int> fac(2000020); iota(fac.begin(), fac.end(), 0); for(int i = 2; i < 2000020; i++){ if(fac[i] != i) continue; int t = i; while(t <= 2000020){ fac[t] = i; t += i; } } int ans = 0; for(int i = L; i <= R; i++){ if(i != 1 && fac[i] == i) ans++; if(i < R){ if(fac[2 * i + 1] == 2 * i + 1) ans++; } } cout << ans << endl; }