結果

問題 No.1458 Segment Function
ユーザー 👑 kakel-sankakel-san
提出日時 2024-05-26 22:32:40
言語 C#
(.NET 8.0.203)
結果
AC  
実行時間 65 ms / 2,000 ms
コード長 1,489 bytes
コンパイル時間 8,191 ms
コンパイル使用メモリ 170,124 KB
実行使用メモリ 186,232 KB
最終ジャッジ日時 2024-05-26 22:32:53
合計ジャッジ時間 12,451 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 52 ms
28,800 KB
testcase_01 AC 52 ms
28,544 KB
testcase_02 AC 53 ms
29,312 KB
testcase_03 AC 52 ms
29,056 KB
testcase_04 AC 54 ms
28,544 KB
testcase_05 AC 54 ms
28,800 KB
testcase_06 AC 65 ms
30,080 KB
testcase_07 AC 53 ms
28,800 KB
testcase_08 AC 57 ms
31,232 KB
testcase_09 AC 56 ms
31,232 KB
testcase_10 AC 57 ms
30,720 KB
testcase_11 AC 58 ms
31,232 KB
testcase_12 AC 56 ms
30,720 KB
testcase_13 AC 52 ms
28,800 KB
testcase_14 AC 52 ms
29,056 KB
testcase_15 AC 52 ms
29,056 KB
testcase_16 AC 52 ms
28,928 KB
testcase_17 AC 52 ms
29,184 KB
testcase_18 AC 56 ms
31,352 KB
testcase_19 AC 56 ms
31,360 KB
testcase_20 AC 57 ms
31,360 KB
testcase_21 AC 59 ms
31,104 KB
testcase_22 AC 58 ms
31,488 KB
testcase_23 AC 54 ms
29,428 KB
testcase_24 AC 52 ms
28,928 KB
testcase_25 AC 54 ms
29,176 KB
testcase_26 AC 56 ms
31,360 KB
testcase_27 AC 57 ms
31,360 KB
testcase_28 AC 50 ms
27,008 KB
testcase_29 AC 52 ms
28,672 KB
testcase_30 AC 52 ms
28,544 KB
testcase_31 AC 51 ms
28,800 KB
testcase_32 AC 57 ms
30,976 KB
testcase_33 AC 57 ms
30,848 KB
testcase_34 AC 57 ms
186,232 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
  復元対象のプロジェクトを決定しています...
  /home/judge/data/code/main.csproj を復元しました (96 ms)。
MSBuild のバージョン 17.9.6+a4ecab324 (.NET)
  main -> /home/judge/data/code/bin/Release/net8.0/main.dll
  main -> /home/judge/data/code/bin/Release/net8.0/publish/

ソースコード

diff #

using System;
using static System.Console;
using System.Linq;
using System.Collections.Generic;

class Program
{
    static int NN => int.Parse(ReadLine());
    static int[] NList => ReadLine().Split().Select(int.Parse).ToArray();
    static int[][] NArr(long n) => Enumerable.Repeat(0, (int)n).Select(_ => NList).ToArray();
    public static void Main()
    {
        Solve();
    }
    static void Solve()
    {
        var c = ReadLine().Split();
        var p = c[0];
        var n = c[1];
        if (n == "0")
        {
            WriteLine(p);
            return;
        }
        var f = Conv(p);
        if (n.Length < 6)
        {
            var m = int.Parse(n) - 1;
            for (var i = 0; i < m; ++i) f = Conv(f);
        }
        else
        {
            var prev = -1;
            while (prev != f)
            {
                prev = f;
                f = Conv(f);
            }
        }
        WriteLine(f);
    }
    static int[] list = new int[] { 6, 2, 5, 5, 4, 5, 6, 4, 7, 6 };
    static int Conv(string s)
    {
        var ans = 0;
        foreach (var c in s)
        {
            if (c == '-') ++ans;
            else ans += list[c - '0'];
        }
        return ans;
    }
    static int Conv(int n)
    {
        if (n == 0) return 6;
        var ans = 0;
        while (n > 0)
        {
            ans += list[n % 10];
            n /= 10;
        }
        return ans;
    }
}
0