View Code of Problem 120

#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
/* run this program using the console pauser or add your own getch, system("pause") or input loop */

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

Double click to view unformatted code.


Back to problem 120