View Code of Problem 120

#include "stdio.h"
#include "math.h"

void main()
{	
	int i,j;
	int a,b,c,d;
	int count;
	int sum;
	int x,y;
	int k,s;
	for(;scanf("%02d:%02d%02d:%02d",&a,&b,&c,&d)!=EOF;)
	{
		sum=0;
		count=c*60+d-a*60-b+1;
	//	printf("%d\n",count);
		for(i=0;i<count;i++)
		{
			k=0;
			x=a+(b+i)/60;
			y=(b+i)%60;		
			s=x*2500+y;
		//	printf("%d %d\n",x,y);
			for(j=2;j<=sqrt(s);j++)
			{
				if(s%j==0)
				{
					k++;
					break;
				}
			}
			if(k==0)
				sum++;
		}
		printf("%d\n",sum);

	}
}

Double click to view unformatted code.


Back to problem 120