結果

問題 No.1849 Three Times Value
ユーザー bluemeganebluemegane
提出日時 2023-08-23 19:59:51
言語 C#(csc)
(csc 3.9.0)
結果
WA  
実行時間 -
コード長 759 bytes
コンパイル時間 2,250 ms
コンパイル使用メモリ 111,576 KB
実行使用メモリ 26,452 KB
最終ジャッジ日時 2024-06-01 17:23:52
合計ジャッジ時間 3,948 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 22 ms
16,896 KB
testcase_02 AC 22 ms
17,280 KB
testcase_03 AC 23 ms
17,920 KB
testcase_04 AC 23 ms
18,048 KB
testcase_05 AC 23 ms
17,792 KB
testcase_06 WA -
testcase_07 AC 22 ms
17,152 KB
testcase_08 AC 22 ms
17,408 KB
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 AC 23 ms
17,792 KB
testcase_16 AC 23 ms
17,408 KB
testcase_17 AC 23 ms
17,280 KB
testcase_18 WA -
testcase_19 WA -
testcase_20 AC 22 ms
17,280 KB
testcase_21 AC 22 ms
17,152 KB
testcase_22 WA -
testcase_23 AC 22 ms
17,280 KB
testcase_24 AC 23 ms
17,280 KB
testcase_25 AC 22 ms
17,408 KB
testcase_26 WA -
testcase_27 AC 24 ms
17,024 KB
testcase_28 AC 22 ms
17,280 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc)
Copyright (C) Microsoft Corporation. All rights reserved.

ソースコード

diff #

using static System.Math;
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 = (int)Pow(10, w - 1) - ww + 1 + ww2;
            if (www > long.Parse(s)) ans--;
            Console.WriteLine(ans);
        }
    }
}
0