結果

問題 No.648  お や す み 
ユーザー Charlotte8687
提出日時 2018-11-28 17:09:05
言語 C#(csc)
(csc 3.9.0)
結果
TLE  
実行時間 -
コード長 858 bytes
コンパイル時間 2,126 ms
コンパイル使用メモリ 107,888 KB
実行使用メモリ 29,424 KB
最終ジャッジ日時 2024-06-26 22:57:56
合計ジャッジ時間 8,219 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 60 TLE * 1 -- * 23
権限があれば一括ダウンロードができます
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc)
Copyright (C) Microsoft Corporation. All rights reserved.

ソースコード

diff #

using System;

namespace StudyApp
{
    class Program
    {
        static void Main(string[] args)
        {
            string input = Console.ReadLine();
            CanSleep(double.Parse(input));
        }

        public static void CanSleep(double target_num)
        {
            double second = 0; // Total seconds
            double sheep_num = 0; // The number of sheep

            while (true)
            {
                sheep_num += second;

                if (target_num > sheep_num)
                    second++;
                else
                    break;
            }

            if (target_num.Equals(sheep_num))
            {
                Console.WriteLine("YES");
                Console.WriteLine(second);
            }
            else
            {
                Console.WriteLine("NO");
            }
        }
    }
}
0