View Code of Problem 120

#include<bits/stdc++.h>
using namespace std;
int main()
{
	int a,b,c,d,h,m,sum,s1,s2,k=0,flag;
	while(scanf("%d:%d",&a,&b)!=EOF)
	{
	scanf("%d:%d",&c,&d);
	s1=a*60+b;
	s2=c*60+d;
	for(int i=s1;i<=s2;i++)
	{
	    flag=0;
	    h=i/60;
	    m=i%60;
	    sum=h*2500+m;
		for(int j=2;j<=sqrt(i);j++)
		{
			if(sum%j==0)
			{
			flag=1;
			break;
			}
	    }
	    if(flag==0)
	    {
		k++;
		}	
	}
	cout<<k<<endl;
	}
	return 0;
 } 

Double click to view unformatted code.


Back to problem 120