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

what's wrong with this program? I got wa
Posted by katarsis 12 Nov 2002 16:18
var p,a,n:longint;
begin
readln(n); p:=n;
while (2*n mod p<>0) or
((2*n-(p+1)*p)<0)
do if p>0 then dec(p) else halt;
a:=(2*n-(p-1)*p) div (2*p);
writeln(a,' ',p);
end.
WA
Posted by I am david. Tabo. 19 Nov 2002 22:36
> var p,a,n:longint;
> begin
> readln(n); p:=n;
> while (2*n mod p<>0) or
> ((2*n-(p+1)*p)<0)
> do if p>0 then dec(p) else halt;
> a:=(2*n-(p-1)*p) div (2*p);
> writeln(a,' ',p);
> end.