結果

問題 No.1849 Three Times Value
ユーザー bluemeganebluemegane
提出日時 2023-08-23 19:24:28
言語 C#(csc)
(csc 3.9.0)
結果
RE  
実行時間 -
コード長 681 bytes
コンパイル時間 2,235 ms
コンパイル使用メモリ 64,968 KB
実行使用メモリ 24,868 KB
最終ジャッジ日時 2023-08-23 19:24:34
合計ジャッジ時間 5,799 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 RE -
testcase_01 WA -
testcase_02 AC 48 ms
20,412 KB
testcase_03 RE -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 AC 50 ms
22,572 KB
testcase_17 AC 48 ms
20,412 KB
testcase_18 RE -
testcase_19 RE -
testcase_20 AC 49 ms
22,468 KB
testcase_21 AC 48 ms
20,416 KB
testcase_22 WA -
testcase_23 AC 48 ms
20,496 KB
testcase_24 AC 52 ms
22,456 KB
testcase_25 AC 47 ms
22,536 KB
testcase_26 WA -
testcase_27 AC 48 ms
20,656 KB
testcase_28 AC 46 ms
18,432 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

using System;

public class Hello
{
    static void Main()
    {
        var s = Console.ReadLine().Trim();
        getAns(s);
    }
    static void getAns(string s)
    {
        var n = s.Length;
        if (n % 3 != 0)
        {
            var w = n / 3;
            Console.WriteLine(new string('9', w));
        }
        else
        {
            var w = n / 3;
            var ws = s.Substring(0, w);
            var ww = int.Parse(ws);
            var www = long.Parse(ws + ws + ws);
            var ww2 = int.Parse(new string('9', w - 1));
            var ans = ww + ww2;
            if (www < long.Parse(s)) ans--;
            Console.WriteLine(ans);
        }
    }
}
0