View Code of Problem 120

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int isPrime(int n){
	if(n<2) return 0;
	for(int i = 2;i*i <= n;i++){
		if(n%i==0) return 0;
	}
	return 1;
}
int main (){
	int h1, m1, h2, m2, h, m;
	while(~scanf("%d:%d", &h1, &m1)){
		scanf("%d:%d", &h2, &m2);
		int t1 = h1*60+m1;
		int t2 = h2*60+m2;
		int cnt = 0;
		for(int i = t1;i <= t2;i++){
			h = i/60, m = i%60;
			if(isPrime(h*2500+m)) cnt++;
		}
		printf("%d\n", cnt);
	}

	return 0;
}

Double click to view unformatted code.


Back to problem 120