View Code of Problem 120

#include <iostream>
#include <cstdio>
#include <cmath>
using namespace std;
int main(){
	int starth,startm,endh,endm;
	while(scanf("%d:%d",&starth,&startm)!=EOF){
		scanf("%d:%d",&endh,&endm);
		int t1,t2;
		t1=starth*60+startm;
		t2=endh*60+endm;
		int cn=0;
		for(int i=t1;i<=t2;i++){
			int sum=i/60*2500+i%60;
			int k=1;
			for(int j=2;j<=sqrt(sum);j++){
				if(i%j==0){
					k=j;
					break;
				}
			}
			if(k==1)
				cn++;
		}
		cout<<cn<<endl;
	}
	return 0;
}

Double click to view unformatted code.


Back to problem 120