Submission #1169317


Source Code Expand

Copy
using System;
using System.Collections.Generic;
public class Aprob {
    public static void Main() {
        int X = int.Parse(Console.ReadLine());
        int X2 = X;
        int X3 = X;
        int count = 0;
        for (int i = 1; true; i++) {
            X -= i;
            if (X > 0) {
                count++;
            } else if (X == 0) {
                count++;
                break;
            } else {
                X += i;
                X += i - 1;
                count += X - (i - 1);
                break;
            }
        }
        int count2 = 0;
        for (int i = 1; true; i++) {
            X2 -= i;
            if (X2 > 0) {
                count2++;
            } else {
                count2++;
                break;
            }
        }
        count2 += (X2 * -2);
        int count3 = 0;
        for (int i = 1; true; i++) {
            X3 -= i;
            if (X3 > 0) {
                count3++;
            } else if (X3 == 0) {
                count3++;
                break;
            } else {
                X3 += i;
                count3++;
                break;
            }
        }
        count3 += X3 * 2;
        Console.WriteLine(Math.Min(Math.Min(count,count2),count3));
    }
}

Submission Info

Submission Time
Task A - HonestOrDishonest
User shomu36
Language C# (Mono 4.6.2.0)
Score 0
Code Size 1301 Byte
Status

Test Cases

Set Name Score / Max Score Test Cases
Sample 0 / 0 0_000.txt, 0_001.txt, 0_002.txt
All 0 / 100 0_000.txt, 0_001.txt, 0_002.txt, 1_003.txt
Case Name Status Exec Time Memory
0_000.txt
0_001.txt
0_002.txt
1_003.txt