View Code of Problem 120

#include<stdio.h>

int main() {
	char start[5],end[5];
	while(scanf("%s %s",start,end)!=EOF) {
		int startH,startM,endH,endM;
		sscanf(start,"%d:%d",&startH,&startM);
		sscanf(end,"%d:%d",&endH,&endM);
		int sum =0;
		while((endH-startH)*60+endM	-startM>=0) {
			int j =1;
			int x=startH*2500+startM;
			for(int i=2; i*i<=x; i++) {
				if(x%i==0) {
					j=0;
					break;
				}
			}
			if(j==1)sum++;
			startM++;
			if(startM==60) {
				startM=0;
				startH++;
			}
		}
		printf("%d\n",sum);
	}

	return 0;
}

Double click to view unformatted code.


Back to problem 120