#include<bits/stdc++.h> using namespace std; void jud(int,int); bool is(int n); int main(){ int x,y; while(scanf("%d%d",&x,&y)!=EOF){ jud(x+1,y-1); } return 0; } void jud(int x,int y){ long sum = 0; for(int i = x;i <= y;i++){ if(is(i)){ sum+=i; } } cout<<sum<<endl; } bool is(int n){ if(n<=1)return false; int sqr = (int)sqrt(1.0*n); for(int i = 2 ;i<=sqr;i++){ if(n%i==0) return false; } return true; } |
Double click to view unformatted code.