#include<iostream> #include<math.h> using namespace std; int isPrime(int x) { int i; for(i=2; i<sqrt(x); i++) { if(x%i==0) break; } if(i>sqrt(x)) return 1; else return 0; } int main() { int T1_H,T1_M,T2_H,T2_M,k; char ch; while(cin>>T1_H>>ch>>T1_M>>T2_H>>ch>>T2_M) { k=0; for(int i=T1_H*60+T1_M;i<=T2_H*60+T2_M; i++) { int H=i/60; int M=i%60; if(isPrime(2500*H+M)&&(2500*H+M)>1) k++; } cout<<k<<endl; } return 0; } |
Double click to view unformatted code.