|
|
back to boardDiscussion of Problem 1068. SumWhy? Wrong answer test#9 Posted by vitalik 28 Nov 2011 20:36 using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace timus { class Program { static void Main(string[] args) { int n = int.Parse(Console.ReadLine()); int s = 0; for (int i = 1; i <= Math.Abs(n); i++) { s += i; } if (n >= 1 && n <= 1000) { Console.WriteLine(s); } else if (n <= 0 && n >= -1000) { Console.WriteLine(-(s - 1)); } } } } |
|
|