#include<stdio.h> #include<string.h> #include<math.h> int main() { char a[10], b[10]; while (scanf("%s",a)!=EOF) { scanf("%s", b); int h1, h2, m1, m2; h1 = (a[0] - '0') * 10 + (a[1] - '0'); h2 = (b[0] - '0') * 10 + (b[1] - '0'); m1 = (a[3] - '0') * 10 + (a[4] - '0'); m2 = (b[3] - '0') * 10 + (b[4] - '0'); int start = h1 * 2500 + m1; int end = h2 * 2500 + m2; int count = 1; for (int i = start; i <= end; i++) { int flag = 1; for (int j = 2; j <= sqrt(i); j++) { if (i%j == 0) { flag = 0; break; } } if (flag) count++; } printf("%d\n", count-1); } return 0; } |
Double click to view unformatted code.