View Code of Problem 120

#include<stdio.h> 
#include<math.h>
typedef struct time{
	int h;
	int m;
}t;
int judge(int n)
{
	if(n==1&&n==0)
	  return 0;
	else if(n==2)
	  return 1;
	else
	{
		int i;
		for(i=2;i<=sqrt(n);i++)
		{
			if(n%i==0)
			  return 0;
		}
		return 1;
	}
}
int main()
{
   t begin,end;
   int sum;
   while(scanf("%d:%d %d:%d",&begin.h,&begin.m,&end.h,&end.m)!=EOF)
   {
   		int sum1=begin.h*60+begin.m;
   		int sum2=end.h*60+end.m;
   		int i,cnt=0;
   		for(i=sum1;i<=sum2;i++)
   		{
   			if(judge((i/60)*2500+(i%60))==1)
   			  cnt++;
		}
		printf("%d\n",cnt);
   	}
}

Double click to view unformatted code.


Back to problem 120