#include "iostream" #include "stdio.h" #include "math.h" #include "algorithm" using namespace std; bool isSu(int n){ for(int i=2;i<=sqrt(n);i++){ if(n%i==0){ return false; } } return true; } int main(){ int a,b; while (scanf("%d %d",&a,&b)!=EOF){ int ans=0; while (a<b){ if(isSu(a)){ ans++; } if(isSu(b)){ ans++; } a++; b--; } if(a==b&&isSu(a)){ ans++; } printf("%d\n",ans); } } |
Double click to view unformatted code.