結果

問題 No.1849 Three Times Value
ユーザー bluemeganebluemegane
提出日時 2023-08-23 19:59:51
言語 C#(csc)
(csc 3.9.0)
結果
WA  
実行時間 -
コード長 759 bytes
コンパイル時間 1,888 ms
コンパイル使用メモリ 64,712 KB
実行使用メモリ 25,136 KB
最終ジャッジ日時 2023-08-23 19:59:57
合計ジャッジ時間 4,987 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 50 ms
22,448 KB
testcase_02 AC 50 ms
20,468 KB
testcase_03 AC 58 ms
22,948 KB
testcase_04 AC 59 ms
20,820 KB
testcase_05 AC 59 ms
22,924 KB
testcase_06 WA -
testcase_07 AC 49 ms
18,484 KB
testcase_08 AC 49 ms
18,568 KB
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 AC 58 ms
23,224 KB
testcase_16 AC 50 ms
20,516 KB
testcase_17 AC 49 ms
20,528 KB
testcase_18 WA -
testcase_19 WA -
testcase_20 AC 49 ms
20,480 KB
testcase_21 AC 51 ms
20,528 KB
testcase_22 WA -
testcase_23 AC 50 ms
20,516 KB
testcase_24 AC 51 ms
18,388 KB
testcase_25 AC 51 ms
20,508 KB
testcase_26 WA -
testcase_27 AC 50 ms
20,408 KB
testcase_28 AC 50 ms
20,396 KB
権限があれば一括ダウンロードができます

ソースコード

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