#include <iostream> #include <math.h> using namespace std; bool isprime(int n){ if(n==1) return true; int bound = (int)sqrt(n)+1; for(int j=2;j<bound;j++){ if(n%j==0) return false; } return true; } int main(){ int h1,m1,h2,m2,sum,count,h,m; while(scanf("%2d:%2d",&h1,&m1)!=EOF){ scanf("%2d:%2d",&h2,&m2); count = 0; time1 = h1*60+m1; time2 = h2*60+m2; for(int j=time1;j<=time2;j++){ m = j%60; h = j/60; if(isprime(h*2500+m)) count++; } printf("%d\n",count); } return 0; } /* Main.cc: In function 'int main()': Main.cc:21:5: error: 'time1' was not declared in this scope time1 = h1*60+m1; ^ Main.cc:22:5: error: 'time2' was not declared in this scope time2 = h2*60+m2; ^ Main.cc:17:19: warning: unused variable 'sum' [-Wunused-variable] int h1,m1,h2,m2,sum,count,h,m; ^ */ |
Double click to view unformatted code.