Submission #1932091
Source Code Expand
#include<bits/stdc++.h> #define rep(i,a,b) for(int i=a;i<b;i++) #define rrep(i,a,b) for(int i=a;i>=b;i--) #define fore(i,a) for(auto &i:a) #pragma GCC optimize ("-O3") using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); } //--------------------------------------------------------------------------------------------------- vector<int> makeBitPrimes(int n) { vector<int> v(n + 1, 1);v[0] = v[1] = 0; rep(i, 2, sqrt(n)) if (v[i]) for (int j = 0; i * (j + 2) < n; j++) v[i * (j + 2)] = 0;return v;} /*--------------------------------------------------------------------------------------------------- ∧_∧ ∧_∧ (´<_` ) Welcome to My Coding Space! ( ´_ゝ`) / ⌒i / \ | | / / ̄ ̄ ̄ ̄/ | __(__ニつ/ _/ .| .|____ \/____/ (u ⊃ ---------------------------------------------------------------------------------------------------*/ int Q; int A[101010], B[101010]; //--------------------------------------------------------------------------------------------------- void _main() { auto ps = makeBitPrimes(101010); rep(i, 1, 101010) if (ps[i] and ps[(i + 1) / 2]) A[i] = 1; rep(i, 1, 101010) B[i] = B[i - 1] + A[i]; cin >> Q; rep(q, 0, Q) { int L, R; cin >> L >> R; int ans = B[R] - B[L - 1]; printf("%d\n", ans); } }
Submission Info
Submission Time | |
---|---|
Task | D - 2017-like Number |
User | hamayanhamayan |
Language | C++14 (GCC 5.4.1) |
Score | 400 |
Code Size | 1592 Byte |
Status | AC |
Exec Time | 27 ms |
Memory | 1792 KB |
Judge Result
Set Name | Sample | All | ||||
---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 400 / 400 | ||||
Status |
|
|
Set Name | Test Cases |
---|---|
Sample | sample_01.txt, sample_02.txt, sample_03.txt |
All | 01.txt, 02.txt, 03.txt, 04.txt, 05.txt, 06.txt, 07.txt, sample_01.txt, sample_02.txt, sample_03.txt |
Case Name | Status | Exec Time | Memory |
---|---|---|---|
01.txt | AC | 27 ms | 1792 KB |
02.txt | AC | 27 ms | 1792 KB |
03.txt | AC | 27 ms | 1792 KB |
04.txt | AC | 27 ms | 1792 KB |
05.txt | AC | 24 ms | 1792 KB |
06.txt | AC | 25 ms | 1792 KB |
07.txt | AC | 27 ms | 1664 KB |
sample_01.txt | AC | 2 ms | 1408 KB |
sample_02.txt | AC | 2 ms | 1408 KB |
sample_03.txt | AC | 2 ms | 1408 KB |