View Code of Problem 120

#include <stdio.h>
#include <math.h>
int isp(int n){
	if(n<=1) return 0;
	int i;
	for(i=2;i<=sqrt(n);i++){
		if(n%i==0) return 0;
	}
	return 1;
} 
int main(){
	int h1,h2,m1,m2,i,j,t1,t2;
	
	while(scanf("%d %d",&t1,&t2)!=EOF){
		if(t1>t2) {
			i=t1;
			t1=t2;
			t2=i;
		}
		h1=t1/100; m1=t1%100;
		h2=t2/100; m2=t2%100;
		printf("%2d:%2d\n",h1,m1);printf("%2d:%2d\n",h2,m2);
		int c=0;
		while(h1<h2||m1<m2){
			 
			if(isp(m1+h1*2500))
				c++;
			m1++;
			if(m1==60){
				m1=0;h1++;
			}
		}
		printf("%d\n",c);
	}
	return 0;
}

Double click to view unformatted code.


Back to problem 120