View Code of Problem 120

#include <iostream>
#include <cstdio>
#include <cmath>
using namespace std;
int main(){
    int a1,b1,a2,b2,m1,m2,s1,s2,k;
    while(~scanf("%d:%d%d:%d",&a1,&b1,&a2,&b2)){
        int flag = 1,t=0;
        m1=a1*60+b1;
        m2=a2*60+b2;
        for(int i=m1;i<=m2;i++){
            flag =1;
            s1=i/60;
            s2=i%60;
            k=s1*2500+s2;
            for(int i=2;i<=sqrt(k);i++){
                if(k%i==0){
                    flag=0;
                }
            }
            if(flag==1){
                t++;
            }
        }
        printf("%d\n",t);
    }
    return 0;
}


Double click to view unformatted code.


Back to problem 120