人們紛紛來到告示前,都想知道誰纔是自己的另一半.告示如下:
數字N的因子就是所有比N小又能被N整除的所有正整數,如12的因子有1,2,3,4,6.
你想知道你的另一半嗎?
Output對於每組測試數據,請輸出一個代表輸入數據N的另一半的編號.
Sample Input
3 2 10 20Sample Output
1 8 22
#include<stdio.h>
#include<math.h>
#include<string.h>
#include<algorithm>
using namespace std;
const int N=500000+10;
int a[N];
int main()
{
int n,num;
scanf("%d",&n);
a[0]=a[1]=1;
for(int i=1; i<=N/2; i++)
for(int j=i*2; j<=N; j+=i)
a[j]+=i;
while(n--)
{
scanf("%d",&num);
printf("%d\n",a[num]);
}
return 0;
}