View Code of Problem 120

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

Double click to view unformatted code.


Back to problem 120