View Code of Problem 120

#include <stdio.h>
#include <string.h> 
int main()
{
	char a[2],b[2];
	int i,j;
	while(scanf("%d:%d",&a[0],&b[0])!=EOF)
	{
		int s,flag=0;
		scanf("%d:%d",&a[1],&b[1]);
		while((a[1]-a[0])*60+b[1]-b[0]>=0) 
		{ 
		    j=1;
		    s=a[0]*2500+b[0];
		    for(i=2;i*i<=s;i++)
		    {   
				if(s%i==0) {
					j=0;break;
				}
			}
			if(j==1) flag++;
			b[0]++;
			if(b[0]==60)
			{
				b[0]=0;
				a[0]++;
			}
        }
		printf("%d\n",flag);
	}
	return 0;
}

Double click to view unformatted code.


Back to problem 120