結果

問題 No.648  お や す み 
ユーザー バカらっくバカらっく
提出日時 2018-02-09 23:07:54
言語 C#(csc)
(csc 3.9.0)
結果
AC  
実行時間 63 ms / 2,000 ms
コード長 1,948 bytes
コンパイル時間 3,678 ms
コンパイル使用メモリ 107,656 KB
実行使用メモリ 22,908 KB
最終ジャッジ日時 2023-10-11 22:09:56
合計ジャッジ時間 10,988 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 61 ms
20,796 KB
testcase_01 AC 60 ms
20,788 KB
testcase_02 AC 61 ms
20,736 KB
testcase_03 AC 61 ms
20,864 KB
testcase_04 AC 60 ms
20,776 KB
testcase_05 AC 61 ms
22,736 KB
testcase_06 AC 60 ms
22,908 KB
testcase_07 AC 60 ms
20,744 KB
testcase_08 AC 60 ms
18,780 KB
testcase_09 AC 61 ms
22,848 KB
testcase_10 AC 61 ms
20,804 KB
testcase_11 AC 60 ms
20,924 KB
testcase_12 AC 61 ms
22,788 KB
testcase_13 AC 61 ms
22,860 KB
testcase_14 AC 61 ms
20,836 KB
testcase_15 AC 60 ms
22,868 KB
testcase_16 AC 61 ms
20,828 KB
testcase_17 AC 60 ms
20,808 KB
testcase_18 AC 61 ms
20,720 KB
testcase_19 AC 60 ms
22,796 KB
testcase_20 AC 62 ms
20,820 KB
testcase_21 AC 62 ms
22,728 KB
testcase_22 AC 61 ms
20,792 KB
testcase_23 AC 61 ms
18,844 KB
testcase_24 AC 61 ms
20,792 KB
testcase_25 AC 61 ms
20,704 KB
testcase_26 AC 62 ms
20,808 KB
testcase_27 AC 61 ms
20,808 KB
testcase_28 AC 61 ms
18,804 KB
testcase_29 AC 61 ms
20,788 KB
testcase_30 AC 61 ms
20,820 KB
testcase_31 AC 61 ms
22,800 KB
testcase_32 AC 62 ms
20,760 KB
testcase_33 AC 60 ms
20,800 KB
testcase_34 AC 60 ms
20,740 KB
testcase_35 AC 61 ms
20,776 KB
testcase_36 AC 61 ms
18,732 KB
testcase_37 AC 62 ms
22,792 KB
testcase_38 AC 59 ms
20,748 KB
testcase_39 AC 60 ms
18,792 KB
testcase_40 AC 60 ms
20,784 KB
testcase_41 AC 59 ms
20,676 KB
testcase_42 AC 60 ms
20,780 KB
testcase_43 AC 62 ms
20,684 KB
testcase_44 AC 63 ms
20,692 KB
testcase_45 AC 60 ms
20,680 KB
testcase_46 AC 60 ms
18,692 KB
testcase_47 AC 62 ms
22,796 KB
testcase_48 AC 61 ms
20,740 KB
testcase_49 AC 61 ms
20,804 KB
testcase_50 AC 62 ms
20,816 KB
testcase_51 AC 61 ms
20,700 KB
testcase_52 AC 62 ms
22,856 KB
testcase_53 AC 63 ms
20,788 KB
testcase_54 AC 62 ms
20,696 KB
testcase_55 AC 63 ms
20,856 KB
testcase_56 AC 62 ms
22,728 KB
testcase_57 AC 62 ms
20,900 KB
testcase_58 AC 61 ms
20,864 KB
testcase_59 AC 62 ms
20,732 KB
testcase_60 AC 61 ms
20,676 KB
testcase_61 AC 62 ms
20,912 KB
testcase_62 AC 62 ms
20,884 KB
testcase_63 AC 61 ms
20,756 KB
testcase_64 AC 61 ms
18,784 KB
testcase_65 AC 61 ms
22,784 KB
testcase_66 AC 61 ms
20,764 KB
testcase_67 AC 61 ms
20,888 KB
testcase_68 AC 61 ms
20,796 KB
testcase_69 AC 61 ms
20,800 KB
testcase_70 AC 62 ms
20,752 KB
testcase_71 AC 62 ms
22,876 KB
testcase_72 AC 60 ms
20,840 KB
testcase_73 AC 62 ms
20,720 KB
testcase_74 AC 60 ms
20,736 KB
testcase_75 AC 61 ms
22,760 KB
testcase_76 AC 61 ms
20,796 KB
testcase_77 AC 62 ms
20,728 KB
testcase_78 AC 61 ms
18,688 KB
testcase_79 AC 62 ms
20,820 KB
testcase_80 AC 62 ms
20,796 KB
testcase_81 AC 61 ms
20,848 KB
testcase_82 AC 62 ms
22,768 KB
testcase_83 AC 63 ms
22,860 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc)
Copyright (C) Microsoft Corporation. All rights reserved.

ソースコード

diff #

using System;
using System.IO;
using System.Linq;
using System.Collections.Generic;
using System.Text;

public class Program
{

    public void Proc()
    {
        long inpt = long.Parse(Reader.ReadLine());
        this.Sheep = inpt;
        Nullable<long> ans = GetAns(1, inpt);
        if(ans == null) {
            Console.WriteLine("NO");
            return;
        }
        Console.WriteLine("YES");
        Console.WriteLine(ans.Value);
    }

    private long Sheep;

    private Nullable<long> GetAns(long min, long max) {
        if(max-min<=1) {
            if(GetNum(max)==this.Sheep) {
                return max;
            } 
            if(GetNum(min)==this.Sheep) {
                return min;
            }

            return null;
        }
        long mid = (max + min) / 2;
        if(mid.ToString().Length>=11) {
            return GetAns(min, mid);
        }
        decimal midNum = GetNum(mid);
        if(midNum==Sheep) {
            return mid;
        }
        if(midNum>Sheep) {
            return GetAns(min, mid);
        } else {
            return GetAns(mid, max);
        }
    }

    private decimal GetNum(long n) {
        decimal tmp = n;
        return n * (n + 1m) / 2m;
    }

    public class Reader
    {
        private static StringReader sr;
        public static bool IsDebug = false;
        public static string ReadLine()
        {
            if (IsDebug)
            {
                if (sr == null)
                {
                    sr = new StringReader(InputText.Trim());
                }
                return sr.ReadLine();
            }
            else
            {
                return Console.ReadLine();
            }
        }
        private static string InputText = @"


2000000000000000000


";
    }

    public static void Main(string[] args)
    {
#if DEBUG
        Reader.IsDebug = true;
#endif
        Program prg = new Program();
        prg.Proc();
    }
}
0