結果

問題 No.1849 Three Times Value
ユーザー bluemeganebluemegane
提出日時 2023-08-23 19:51:41
言語 C#(csc)
(csc 3.9.0)
結果
WA  
実行時間 -
コード長 707 bytes
コンパイル時間 2,317 ms
コンパイル使用メモリ 62,928 KB
実行使用メモリ 22,816 KB
最終ジャッジ日時 2023-08-23 19:51:47
合計ジャッジ時間 5,134 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 59 ms
22,684 KB
testcase_01 AC 51 ms
18,504 KB
testcase_02 AC 52 ms
22,436 KB
testcase_03 AC 58 ms
20,580 KB
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 AC 50 ms
20,308 KB
testcase_08 AC 52 ms
20,440 KB
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
20,380 KB
testcase_17 AC 51 ms
20,360 KB
testcase_18 AC 58 ms
20,652 KB
testcase_19 AC 58 ms
20,716 KB
testcase_20 AC 50 ms
20,308 KB
testcase_21 AC 50 ms
20,460 KB
testcase_22 WA -
testcase_23 AC 50 ms
18,416 KB
testcase_24 AC 51 ms
20,452 KB
testcase_25 AC 50 ms
20,372 KB
testcase_26 WA -
testcase_27 AC 52 ms
20,292 KB
testcase_28 AC 50 ms
20,316 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(w > 0 ? new string('9', w) : "0");
        }
        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 = w > 1 ? int.Parse(new string('9', w - 1)) : 0;
            var ans = ww + ww2;
            if (www > long.Parse(s)) ans--;
            Console.WriteLine(ans);
        }
    }
}
0