Submission #1927260


Source Code Expand

Copy
#include <iostream>
#include <math.h>

using namespace std;

int odd_check(int num){
  if(num<2){
    return 0;
  }
  else if(num == 2){
    return 1;
  }
  else if(num % 2 == 0){
    return 0;
  }
  
  for(int i = 3; i <= sqrt(num); i +=2){
    if(num%i==0){
      return 0;
    }
  }

  return 1;
  
}

int main(){

  int Q,l[100001]={},r[100001]={};

  cin >> Q;

  for(int i = 1; i <= Q; i++){
    cin >> l[i] >> r[i];
  }

  for(int i = 1; i <= Q; i++){
    int cnt = 0;
    for(int j = l[i]; j <= r[i]; j += 2){
      if(odd_check(j)){
	if(odd_check((j+1)/2)){
	  cnt++;
	}
      }
    }
    cout << cnt << "\n";
  }
  
  return 0;
}

Submission Info

Submission Time
Task C - Special Trains
User hazuki00
Language C++14 (GCC 5.4.1)
Score 0
Code Size 690 Byte
Status WA
Exec Time 299 ms
Memory 1024 KB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 0 / 300
Status
WA × 3
WA × 15
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, 08.txt, 09.txt, 10.txt, 11.txt, 12.txt, sample_01.txt, sample_02.txt, sample_03.txt
Case Name Status Exec Time Memory
01.txt WA 249 ms 1024 KB
02.txt WA 299 ms 1024 KB
03.txt WA 274 ms 1024 KB
04.txt WA 271 ms 1024 KB
05.txt WA 10 ms 1024 KB
06.txt WA 2 ms 1024 KB
07.txt WA 194 ms 1024 KB
08.txt WA 233 ms 1024 KB
09.txt WA 9 ms 1024 KB
10.txt WA 85 ms 1024 KB
11.txt WA 217 ms 1024 KB
12.txt WA 41 ms 1024 KB
sample_01.txt WA 2 ms 1024 KB
sample_02.txt WA 2 ms 1024 KB
sample_03.txt WA 2 ms 1024 KB