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 1068. Sum

JAVA - Ошибка на тесте №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