View Code of Problem 120

#include<stdio.h>
#include<math.h>

int main()
{
	int h1, m1, h2, m2;
	int t1, t2;
	int flag, count;
	while(scanf("%d:%d", &h1, &m1) != EOF)
	{
		count = 0;
		scanf("%d:%d", &h2, &m2);
		t1 = h1*2500 + m1;
		t2 = h2*2500 + m2;
		for(int i = t1; i <= t2; i++)
		{
			flag = 1;
			for(int j = 2; j <= sqrt(i); j++)
				if(i%j == 0)
				{
					flag = 0;
					break;
				}
			if(flag)
				count++;
		}
		printf("%d\n", count);
	}
	return 0;
}

Double click to view unformatted code.


Back to problem 120