#include<stdio.h> #include<math.h> int prime(int n){ if(n==0||n==1)return 0; if(n==2)return 1; for(int i=2;i<=sqrt(n);i++){ if(n%i==0){ return 0; break; } } return 1; } int main(){ int h1,m1,h2,m2,t1,t2,t,h,m,cout; while(scanf("%d:%d %d:%d",&h1,&m1,&h2,&m2)!=EOF){ cout=0; t1=h1*60+m1; t2=h2*60+m2; t=t1; h=h1; m=m1; while(t>=t1&&t<=t2){ if(prime(h*2500+m))cout++; t++; h=t/60; m=t%60; } printf("%d\n",cout); } } |
Double click to view unformatted code.