View Code of Problem 120

#include <stdio.h>
#include <stdlib.h>
#include<ctype.h>
#include<string.h>
#include<math.h>
int sushu( int a)
{
	int flag = 0;
		for (int i = 2; i*i <= a; i++)
		{
			if (a%i == 0)
			{
				flag = 1;
				break;
			}
		}
		return flag;
}
int main()
{
	int h1,h2, m1, m2,a,b,h,m;
	while (scanf("%d:%d%d:%d", &h1, &m1,&h2,&m2)!=EOF)
	{
		a = h1 * 60 + m1;
		b = h2 * 60 + m2;
		int k = 0;
		
		for (int i = a; i <= b; i++)
		{
			h = i / 60;
			m = i % 60;

			if (sushu(h*2500+m) == 0)
				k++;
		}
		printf("%d\n", k);
	}
	return 0;
}

Double click to view unformatted code.


Back to problem 120