标签:
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 22289 Accepted Submission(s):
8150
1 #include <iostream> 2 #include <cstdio> 3 using namespace std; 4 int _is(int x) 5 { 6 int i,j,k,l,sum=1; 7 for(i=2;i<=x/2;i++) 8 { 9 if(x%i==0) 10 { 11 sum+=i; 12 } 13 } 14 if(sum==x) 15 return 1; 16 return 0; 17 } 18 int main() 19 { 20 int x,y,i,j,n; 21 cin>>n; 22 while(n--) 23 { 24 int count=0; 25 scanf("%d%d",&x,&y); 26 if(x>y) 27 { 28 int t; 29 t=x; 30 x=y; 31 y=t; 32 } 33 for(i=x;i<=y;i++) 34 { 35 if(_is(i)) 36 { 37 count++; 38 } 39 } 40 printf("%d\n",count); 41 } 42 43 }
居然因为交换错了好几把。。。。,还有坑点是num1可以大于num2
标签:
原文地址:http://www.cnblogs.com/a1225234/p/4690612.html