标签:
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 23233 Accepted Submission(s):
8456
#include<stdio.h> #include<string.h> #include<math.h> #define MAX 10100 #include<algorithm> using namespace std; int wa[MAX],ans[MAX]; void biao() { int i,j; memset(wa,0,sizeof(wa)); memset(ans,0,sizeof(ans)); for(i=1;i<MAX;i++) { int sum=0; for(j=1;j<=(i+1)/2;j++) { if(i%j==0) sum+=j; } if(sum==i) wa[i]=1; } wa[1]=0; for(i=1;i<MAX;i++) { if(wa[i]) ans[i]=ans[i-1]+1; else ans[i]=ans[i-1]; } } int main() { int t,n,m,i; scanf("%d",&t); biao(); while(t--) { scanf("%d%d",&n,&m); int a=min(n,m); int b=max(n,m); printf("%d\n",ans[b]-ans[a-1]); } return 0; }
标签:
原文地址:http://www.cnblogs.com/tonghao/p/4951199.html