View Code of Problem 120

#include<stdio.h>
#include<math.h>
int isprime(int x)
{
	int i;
	if(x<=1)	return 0;
	for( i=2;i<=sqrt(x);++i){
		if(x%i==0)	return 0;
	}
	return 1;
 } 
int main()
{
	int h,h1,s,s1,t,t1,i,h2,s2,t2,count;
	while(scanf("%d:%d",&h,&s)!=EOF){
		scanf("%d:%d",&h1,&s1);
		count=0;
		t=h*60+s;
		t1=h1*60+s1;
		for(i=t;i<=t1;++i){
			h2=i/60;
			s2=i%60;
			t2=h2*2500+s2;
			if(isprime(t2))	count++; 
		}
		printf("%d\n",count);
		
	}
}

Double click to view unformatted code.


Back to problem 120