标签:using pre size namespace name hint nbsp names 题目
给定2个整数a,b 求出它们之间(不含a,b)所有质数的和。
一行,a b(0<=a,b<=65536)
一行,a,b之间(不含a,b)所有素数的和。
39 1224
111390
注意没有要求a<b
1 #include <algorithm> 2 #include <iostream> 3 #include <cstdio> 4 5 using namespace std; 6 7 int a,b,ans; 8 9 bool judge(int x) 10 { 11 for(int i=2;i*i<=x;i++) 12 if(x%i==0) return 0; 13 return 1; 14 } 15 16 int main() 17 { 18 scanf("%d%d",&a,&b); 19 int aa=min(a,b),bb=max(a,b); 20 for(int i=aa+1;i<bb;i++) 21 if(judge(i)) 22 ans+=i; 23 printf("%d",ans); 24 return 0; 25 }
标签:using pre size namespace name hint nbsp names 题目
原文地址:http://www.cnblogs.com/Shy-key/p/6665528.html