Submission #10231049
Source Code Expand
#include <bits/stdc++.h> using namespace std; #define ll long long const int MAX = 1e5 + 10; int prime[MAX], tag[MAX], f[MAX]; void is_Prime(){ int cnt = 0; prime[++cnt] = 2; tag[1] = 1; for( int i = 2; i < MAX; i++){ if(!tag[i]) prime[++cnt] = i; for(int j = 1; j <= cnt && i * prime[j] < MAX; j++){ tag[i * prime[j]] = 1; if( i % prime[j] == 0) break; } } } int main(){ int t, l, r, num = 0; is_Prime(); for (int i=1; i <= MAX; i++) { if(tag[i] == 0 && tag[(i+1)/2] == 0 && i != 2) { f[i]=f[i-1]+1; } else f[i]=f[i-1]; } cin >> t; while(t--){ scanf("%d%d", &l, &r); printf("%d\n", f[r] - f[l - 1]); } return 0; }
Submission Info
Submission Time | |
---|---|
Task | D - 2017-like Number |
User | luogu_bot5 |
Language | C++ (GCC 5.4.1) |
Score | 400 |
Code Size | 759 Byte |
Status | AC |
Exec Time | 29 ms |
Memory | 1408 KB |
Compile Error
./Main.cpp: In function ‘int main()’: ./Main.cpp:35:24: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result] scanf("%d%d", &l, &r); ^ ./Main.cpp:26:17: warning: iteration 100009u invokes undefined behavior [-Waggressive-loop-optimizations] if(tag[i] == 0 && tag[(i+1)/2] == 0 && i != 2) ^ ./Main.cpp:24:18: note: containing loop for (int i=1; i <= MAX; i++) ^
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 | 29 ms | 1408 KB |
02.txt | AC | 29 ms | 1408 KB |
03.txt | AC | 29 ms | 1408 KB |
04.txt | AC | 29 ms | 1408 KB |
05.txt | AC | 26 ms | 1408 KB |
06.txt | AC | 27 ms | 1408 KB |
07.txt | AC | 29 ms | 1280 KB |
sample_01.txt | AC | 2 ms | 1024 KB |
sample_02.txt | AC | 2 ms | 1024 KB |
sample_03.txt | AC | 2 ms | 1024 KB |