Ответы и объяснения

2011-12-15T14:02:39+00:00

#include <stdio.h>
# define IN "input.txt"
# define OUT "output.txt"
unsigned long long sum(int n){
unsigned long long otv=0;
for (int i=1; i*i<=n; i++)
if (!(n%i)){
otv+=i;
if(i*i!=n)otv+=n/i;}
return otv;}
int main(void){
unsigned long long n,otv=0;
freopen(IN,"r",stdin);
freopen(OUT,"w",stdout);
scanf("%I64d",&n);
otv=sum(n);
printf("%I64d",otv);
return 0;}

2011-12-15T17:57:48+00:00

var

 n,i,z:integer;

begin

 readln(n);

for i:=1 to n do if n mod i=0 then inc(z,i);

writeln(z);

end.