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

Don't know this is wrong
Posted by Konjoh Elvis 19 Apr 2015 18:14

import java.io.PrintStream;
import java.util.Scanner;

public class _1068 {


    PrintStream         out     ;
    Scanner             sc;
    public _1068()
    {
        try {
            sc       = new Scanner(System.in);
            out     = System.out;
        } catch (Exception e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
    }

    protected void run() throws Exception {
        int n = sc.nextInt();
        int nb = Math.abs(n);
        if(n<0)
        nb+=2;
        out.println(((nb)*(n+1))/2);

        sc.close();
        out.close();
    }

    public static void main(String args[]) throws Exception {
        new _1068().run();
    }

}