|
|
вернуться в форумsomething else wrong too... program sum(input,output); var n,result : longint; begin readln(n); if n >= 0 then result := n * (n+1) div 2 else result := 1 + n * (1-n) div 2; writeln(result); end. when i tried this, i got WA(in case u are wondering, 0(0+1)/2 = 0), however when i changed to the following i got AC... program sum(input,output); var n,result : longint; begin readln(n); result := 0; if n > 0 then result := n * (n+1) div 2 else result := 1 + n * (1-n) div 2; writeln(result); end. not that i'm insulting the compiler but the only conclusion i can come to is the compiler thinks that 0(0+1)/2 <> 0... btw, 1 + 0(1-0) div 2 = 0 too |
|
|