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,k;
    while(~scanf("%d:%d%d:%d",&h1,&m1,&h2,&m2)){
        k=0;
        sum1=h1*60+m1;
        sum2=h2*60+m2;
        for(int i=sum1;i<=sum2;i++){
            h=i/60;
            m=i%60;
            sum=h*2500+m;
            int flag=1;
            for(int j=2;j<=sqrt(sum);j++){
                if(sum%j==0){
                    flag=0;
                    break;
                }
            }
            if(flag==1)
                k++;
        }
        printf("%d\n",k);
    }
    return 0;
}

Double click to view unformatted code.


Back to problem 120