The Double Seventh Festival, on the 7th day of the 7th lunar month, is a traditional festival full of romance. On that day, the God of the Love came to the digital kingdom, and annunciated to the people:Notification
Do you want to know who is your fere? You can find him or her by this means: Please add all the factors of your ID-Card-Number, and you can find this is your fere's ID-Card-Number.The factors of a numer N is the numbers,they being small than the number N ,and can being divided exactly by the number N. For example, the number 12 has the factors, such as 1,2,3,4,6.
Input
The fist line is the number T (1 <= T <= 500000), indicated the number of the test cases. The next T lines, each line has one integer N( 1 <= N <= 500000), meaning the ID-Card-Number.
Output
For each test case, you should output the fere's ID-Card-Number on a line.
Sample Input
3 2 10 20
Sample Output
1 8 22
刚开始想了很多诸如自定义函数,先全定义在搜索,当然,时间长到都无法输入了/摊手/摊手(中了八皇后的毒)
View Code
![](https://images.cnblogs.com/OutliningIndicators/ContractedBlock.gif)
1 #include <cstdio> 2 #include <cstring> 3 int main() 4 { 5 int n,m; 6 while( scanf("%d",&n)!=EOF) 7 { 8 while(n--) 9 { 10 int sum=0; 11 scanf("%d",&m); 12 for(int i=1;i*i<=m;i++) //先直接把循环次数/2 13 { 14 if(m%i==0) 15 sum+=i+m/i; //竟然没想到=-= 这样就可以顾及到后面的了 16 if(i*i==m) 17 sum-=i; //上面那种会多出来的 18 } 19 printf("%d ",sum-m); //与1对应的 20 } 21 22 } 23 return 0; 24 }