View Code of Problem 120

#include <stdio.h>
#include <math.h>
using namespace std;
int main(){
	
	int h1,m1;
	int h2,m2;
	while( ~scanf("%d:%d %d:%d", &h1, &m1, &h2, &m2 )){
		int cnt = 0;
		int s1 = h1*60+m1;
		int s2 = h2*60+m2;
		for( int i=s1; i<= s2; i++ ){
			int h = i/60;
			int m = i%60;
			int s = h*2500 + m;
			int flag = 1;
			for( int i=2; i<=sqrt(s); i++ ){
				if( s%i == 0 ){
					flag = 0;
					break;
				}
			}
			if( flag == 1 ) cnt++;
		}
		printf("%d\n", cnt );
	}

	return 0;
	
}

Double click to view unformatted code.


Back to problem 120