|
|
back to boardDiscussion of Problem 1068. SumDon't know this is wrong 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(); } } |
|
|