Untouchable
Time Limit: 2000/1000 MS (Java/others) memory limit: 65536/32768 K (Java/others) total submission (s): 8154 accepted submission (s): 2095
Problem descriptions (n) is the sum of the true factors of positive integer N, that is, the sum of the factors less than N and Division N. for example, S (12) = 1 + 2 + 3 + 4 + 6 = 16. if any
If neither m nor S (m) is equal to N, N is considered untouchable.
Input contains multiple groups of data. Input t indicates that there are T groups of data. N (2 <= n <= 1000) is given for one row of data in each group.
Output: If n is an untouchable number, output yes; otherwise, output No
Sample Input
3258
Sample output
yesyesno
At first, I couldn't figure out why wa, but I learned it only after reading a piece of data. In fact, a very large number of factors will also be relatively small passing numbers, for example, 10 and 49, 10 only have 1.7 for 1.2.5 and 49, so it seems that the number to be tested will definitely exceed the required n.
#include <iostream>using namespace std;int main (void){ int n,m,i,j,k,l; int s[500005]={0},ss[1111]={0}; for(i=1;i<250005;i++) for(j=i+i;j<500005;j+=i) s[j]+=i; for(i=0;i<500005;i++) if(s[i]<1001)ss[s[i]]=1; cin>>m; while(m--&&cin>>n) { if(ss[n]==0)cout<<"yes"<<endl; else cout<<"no"<<endl; } return 0;}