ENG  RUSTimus Online Judge
Online Judge
Problems
Authors
Online contests
About Online Judge
Frequently asked questions
Site news
Webboard
Links
Problem set
Submit solution
Judge status
Guide
Register
Update your info
Authors ranklist
Current contest
Scheduled contests
Past contests
Rules
back to board

Discussion of Problem 1120. Sum of Sequential Numbers

Could anybody check my program? Why WA :=( ?Thanks
Posted by Serega 27 Aug 2003 14:36
var n,p,a,i:longint;
    x:real;
function sum(x:integer):longint;
begin
  sum:=round((x*x+x)/2);
end;
begin
  readln(n);
  if n=0 then
  begin
    writeln(0,' ',0);
    halt;
  end;

  for i:=round(sqrt(n)) downto 1 do
  begin
    x:=(n-sum(i-1))/i;
    if x>=0 then
    if x=trunc(x) then
    begin
      writeln(x:0:0,' ',i);
      halt;
    end;
  end;
end.