View Code of Problem 120

#include<stdio.h>
#include<math.h>
#include<stdlib.h>
int ss(int x)
{
	if (x == 0||x==1)
		return 0;
	for (int i = 2; i < x; i++)
	{
		if (x%i == 0)
			return 0;
	}
	return 1;
}
int main()
{
	int h1, h2, m1, m2, sum1, sum2;
	while (scanf("%d:%d %d:%d",&h1,&m1,&h2,&m2) != EOF)
	{
		int n = 0;
		sum1 = h1 * 2500 + m1;
		sum2 = h2 * 2500 + m2;
		while (sum1 <= sum2)
		{
			if (ss(sum1))
				n++;
			m1++;
			if (m1 == 60) 
			{
				m1 = 0;
				h1 = h1 + 1;
			}
			sum1 = h1 * 2500 + m1;
		}
		printf("%d\n",n);
	}
	return 0;
}

Double click to view unformatted code.


Back to problem 120