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

Почему выдаёт, что неверный ответ? С#
Posted by KrulTepes 16 Feb 2017 22:18
using System;

namespace ConsoleApplication
{
    internal class Program
    {
        public static void Main(string[] args)
        {
            var i = Convert.ToInt32(Console.ReadLine());
            var v = i;
            var b = v;
            var z = Math.Abs(i);
            var x = 0;
            if (b<0)
            {
                x = -2;
            }
            else
            {
                x = 0;
            }
            var sum = 0;
            while (x!=z)
            {
                sum = sum + v;
                if (b<0)
                {
                    v++;
                }
                else
                {
                    v--;
                }
                x++;
            }
            Console.WriteLine(sum);
        }
    }
}