View Code of Problem 120

#include <iostream>
#include <cstdio>
#include <cmath>
using namespace std;
int main(){
    int h1,h2,m1,m2,h,m,sum1,sum2,sum,flag,t;
    while(~scanf("%d:%d",&h1,&m1)){
        scanf("%d:%d",&h2,&m2);
        flag=1,t=0;
        sum1=h1*60+m1;
        sum2=h2*60+m2;
        for(int i=sum1;i<=sum2;i++){
            flag=1;
            h=i/60;
            m=i%60;
            sum=h*2500+m;
            for(int i=2;i<=sqrt(sum);i++){
                if(sum%i==0){
                    flag=0;
                    break;
                }
            }
            if(flag==1)
                t++;
        }
        cout<<t<<endl;
//        printf("%d\n",t);
    }
    return 0;
}

Double click to view unformatted code.


Back to problem 120