View Code of Problem 120

#include<stdio.h>
#include<math.h>
int sushu(int n){
	int i;
	for(i=2;i*i<=n;i++)
		if (n%i==0)
		{
			return 0;
			break;
		}
		return 1;
}
int main(){
	int h1,h2,m1,m2,sum,i,h,m,t1,t2;	
   
	while(scanf("%d:%d",&h1,&m1)!=EOF)
	{
		scanf("%d:%d",&h2,&m2);
		t1=h1*60+m1;
		t2=h2*60+m2;
			for(sum=0,i=t1;i<=t2;i++)
			{
				h=i/60;
				m=i%60;
				if (sushu(h*2500+m))
					sum++;
			}	
		printf("%d\n",sum);
	}
	return 0;
}

Double click to view unformatted code.


Back to problem 120