From b7e55e6510690093d61f9cc1152e0330e55fe90b Mon Sep 17 00:00:00 2001 From: Raphael McSinyx Date: Tue, 28 Feb 2017 11:34:35 +0700 Subject: Update others/volume1 --- others/volume1/022.pas | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 others/volume1/022.pas (limited to 'others/volume1/022.pas') diff --git a/others/volume1/022.pas b/others/volume1/022.pas new file mode 100644 index 0000000..87c1d15 --- /dev/null +++ b/others/volume1/022.pas @@ -0,0 +1,31 @@ +var + s: array[1..1000000] of int32; + m, n, i, j: int32; + +begin + readln(m); + s[1] := 0; + for i := 2 to m do + begin + n := trunc(sqrt(i)); + if i mod n > 0 then + s[i] := 1 + else if i = n * n then + s[i] := 1 + n + else + s[i] := 1 + n + i div n; + for j := 2 to n - 1 do + if i mod j = 0 then + inc(s[i], j + i div j) + end; + + j := 0; + for i := 2 to m do + if (i <> s[i]) and + (s[i] <= 1000000) and + (i = s[s[i]]) then + begin writeln(i, ' ', s[i]); + inc(j); + end; + writeln(j div 2) +end. -- cgit 1.4.1