#include <stdio.h> #include <math.h> int isp(int n){ if(n<=1) return 0; int i; for(i=2;i<=sqrt(n);i++) if(n%i==0) return 0; return 1; } int main(){ int n,h1,m1,h2,m2,c=0,i,j; while(scanf("%2d:%2d",&h1,&m1)!=EOF){ scanf("%2d:%2d",&h2,&m2); c=0; if(h2-h1==0) { for(i=m1;i<=m2;i++) if(isp(i)) c++; } else { for(i=m1;i<=59;i++) if(isp(h1*2500+i)) c++; for(i=0;i<m2;i++) if(isp(h2*2500+i)) c++; if(h2-h1>=2) for(i=h1+1;i<h2;i++) for(j=0;j<=59;j++) if(isp(i*2500+j)) c++; } printf("%d\n",c); } return 0; } |
Double click to view unformatted code.