結果
問題 | No.1458 Segment Function |
ユーザー |
|
提出日時 | 2024-05-26 22:32:40 |
言語 | C# (.NET 8.0.404) |
結果 |
AC
|
実行時間 | 63 ms / 2,000 ms |
コード長 | 1,489 bytes |
コンパイル時間 | 7,880 ms |
コンパイル使用メモリ | 165,704 KB |
実行使用メモリ | 187,236 KB |
最終ジャッジ日時 | 2024-12-20 20:28:32 |
合計ジャッジ時間 | 11,480 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 32 |
コンパイルメッセージ
復元対象のプロジェクトを決定しています... /home/judge/data/code/main.csproj を復元しました (100 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/
ソースコード
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;}}