|
|
back to boardDiscussion of Problem 1068. SumJAVA - Ошибка на тесте №2 Posted by Igor 2 Feb 2015 00:13 import java.io.*; import java.util.*; public class qw { public static void main(String[] args) { Scanner in = new Scanner(System.in); PrintWriter out = new PrintWriter(System.out); int n = in.nextInt(); int res = 0; if(n > 0) { for(int i = 2; i <= n; i++) { res += i; } } else if(n < 0) { for(int i = -2; i >= n; i--) { res += i; } } else res = 0;
if(-10000 <= n & n <= 10000)out.println(res); out.flush(); } } Edited by author 02.02.2015 00:14 |
|
|