結果
| 問題 | 
                            No.1657 Sum is Prime (Easy Version)
                             | 
                    
| コンテスト | |
| ユーザー | 
                             batsumaru
                         | 
                    
| 提出日時 | 2021-08-27 22:01:15 | 
| 言語 | C++14  (gcc 13.3.0 + boost 1.87.0)  | 
                    
| 結果 | 
                             
                                AC
                                 
                             
                            
                         | 
                    
| 実行時間 | 15 ms / 2,000 ms | 
| コード長 | 829 bytes | 
| コンパイル時間 | 1,427 ms | 
| コンパイル使用メモリ | 169,512 KB | 
| 実行使用メモリ | 11,048 KB | 
| 最終ジャッジ日時 | 2024-11-21 02:23:47 | 
| 合計ジャッジ時間 | 2,361 ms | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge3 / judge4 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 3 | 
| other | AC * 21 | 
ソースコード
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define FOR(i, m, n) for (ll i = m; i < n; i++)
#define IFOR(i, m, n) for (ll i = n - 1; i >= m; i--)
#define REP(i, n) FOR(i, 0, n)
#define IREP(i, n) IFOR(i, 0, n)
#define ALL(v) (v).begin(), (v).end()
#define SZ(x) ll(x.size())
vector<int> Eratosthenes(ll n) {
  vector<int> res(n + 1, 1);
  res[0] = res[1] = 0;
  for (ll i = 2; i * i <= n; i++)
    if (res[i]) {
      for (ll j = 2; i * j <= n; j++) res[i * j] = 0;
    }
  return res;
}
int main() {
  ll l, r;
  cin >> l >> r;
  auto v = Eratosthenes(2 * r);
  ll ans = 0;
  FOR(i, l, r + 1) {
    if (v[i]) {
      ans++;
    }
  }
  FOR(i, 2 * l + 1, 2 * r) {
    if (v[i]) {
      ans++;
    }
  }
  cout << ans << endl;
}
            
            
            
        
            
batsumaru