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. Что не так?
Posted by Alex 13 Apr 2017 18:52
import java.util.Scanner;


public class r1068 {
    public static void main(String[] args) {
        Scanner rr = new Scanner(System.in);
        int n = rr.nextInt();
        int w=0;
        if ((n>=1)&&(n<=10000)) {
            for(int i=1; i<=n;i++){
                w=w+i;
            }
            System.out.println(w);
        }
        if ((n<=1)&&(n>=-10000)) {
            for (int i=1; i<=Math.abs(n); i++){
                w=w+(-i);
            }
            System.out.println(w+1);
        }
    }
}

Edited by author 13.04.2017 18:52
Re: Java. Что не так?
Posted by sleepwalker 13 Apr 2017 19:44
Test input: 1

Edited by author 13.04.2017 19:44