【DidaOJ】[1131]Thanksgiving KK Special - A Special Contest Date

Problem Description

Loading...

Problem Analysis

Squeezing out some time for rehabilitation training, and still jotting down the problems I’ve done.

cpp
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#include<stdio.h>  
int main(){  
    int i,k;  
    int a[35]={0};  
    for(a[0]=a[1]=1,i=2;i<35;i++){  
       if(!a[i])  
          for(k=i+i;k<35;k+=i)  
             a[k]=1;  
    }  
    int t,y,d,sum;  
    int j;  
    scanf("%d",&t);  
    while(t--){  
       sum=0;  
       scanf("%d-%d",&y,&d);  
       for(j=2;j<y;j++){  
          if(j==2)  
             sum+=9;  
          if(j==3||j==5||j==7)  
             sum+=11;  
          if (j==11)  
             sum+=10;  
       }  
       if(!a[y]){  
          for(j=2;j<d;j++){  
             if(!a[j])  
                sum++;  
          }  
       }  
       printf("%d\n",sum);  
    }  
    return 0;  
}  

Problem link: Thanksgiving KK Special — A Special Contest Date - Problem Details - Problems - DidaOJ

This post is licensed under CC BY-NC-SA 4.0. If it helped, or if you have anything to say, the comment box below is open.
Page views —
Unique visitors —

Loading...