View Code of Problem 120

#include<iostream>
#include<math.h>
using namespace std;
bool isprime(int x){
	for(int i=2;i<=x/2;i++){
		if(x%i==0)return false;
	}
	return true;
}
int main(){
	int h1,m1,s1,h2,m2,s2,h,m;
	char a,b;
	while(cin>>h1>>a>>m1>>h2>>b>>m2){
		s1=h1*60+m1;
		s2=h2*60+m2;
		int k=0;
		for(int i=s1;i<=s2;i++){
			h=i/60;
			m=i%60;
			if(isprime(h*2500+m))
				k++;
		}
		cout<<k<<endl;
	}
	return 0;
}

Double click to view unformatted code.


Back to problem 120