-
Notifications
You must be signed in to change notification settings - Fork 0
/
C.cpp
43 lines (41 loc) · 773 Bytes
/
C.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#include<bits/stdc++.h>
using namespace std;
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL)
long long ara[100005],c,ans[100005];
int main()
{
fastio;
long long n,i,j,x;
cin>>n;
for(i=1;i*i<=n;i++)
{
if(n%i==0)
{
if(i*i==n)
{
ara[c]=i;
c++;
}
else
{
ara[c]=i;
ara[c+1]=n/i;
c+=2;
}
}
}
for(i=0;i<c;i++)
{
if(i==0)
ans[i]=(n*(n+1))/2;
else
{
x=n/ara[i]-1;
ans[i]=((x*(x+1))/2)*ara[i]+x+1;
}
}
sort(ans,ans+c);
for(i=0;i<c;i++)
cout<<ans[i]<<" ";
return 0;
}