|
|
вернуться в форумI know why does many people got WA!!!!!!!!!!!! When the n is 0,the result must be 1!!!!!!!!!!!!!! (I'm not from the English-speaking country,my English is very bad.) If there's someting wrong,please tell me,thanks) instead of suming u can use this formula : 1+2+3+...+n := n*(n+1) /2; here is my prog : ioi_khafan@hotmail.com var n : longint; begin read (n); if n = 0 then begin writeln ('1'); exit; end else if n > 0 then n := ( n * (n + 1) ) div 2 else begin n := -1 * n; n := ( n * (n + 1) ) div 2; n := n - 1; n := -1 * n; end; writeln (n); end. Var n :integer; sum :longint; begin readln(n); if n=0 then n:=1; sum:=abs(n)*(abs(n)+1) div 2; if n<0 then sum:=1-sum; writeln(sum); readln; end. Thanks! BTW,I am familiar with your english. Beacuse I can read Chnglish at ZJU. -_-|| thanks for the help As you see my English too not so ! |
|
|