結果

問題 No.2649 [Cherry 6th Tune C] Anthem Flower
ユーザー 👑 kakel-sankakel-san
提出日時 2024-02-23 21:50:00
言語 C#
(.NET 8.0.203)
結果
AC  
実行時間 557 ms / 2,000 ms
コード長 1,693 bytes
コンパイル時間 8,294 ms
コンパイル使用メモリ 156,984 KB
実行使用メモリ 218,180 KB
最終ジャッジ日時 2024-02-23 21:50:27
合計ジャッジ時間 17,107 ms
ジャッジサーバーID
(参考情報)
judge16 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 78 ms
33,060 KB
testcase_01 AC 395 ms
70,232 KB
testcase_02 AC 380 ms
70,232 KB
testcase_03 AC 378 ms
70,236 KB
testcase_04 AC 388 ms
70,232 KB
testcase_05 AC 546 ms
70,228 KB
testcase_06 AC 557 ms
70,228 KB
testcase_07 AC 108 ms
42,788 KB
testcase_08 AC 113 ms
42,788 KB
testcase_09 AC 90 ms
35,364 KB
testcase_10 AC 93 ms
35,364 KB
testcase_11 AC 84 ms
33,316 KB
testcase_12 AC 80 ms
33,316 KB
testcase_13 AC 111 ms
38,260 KB
testcase_14 AC 110 ms
37,656 KB
testcase_15 AC 114 ms
37,924 KB
testcase_16 AC 110 ms
37,904 KB
testcase_17 AC 111 ms
40,484 KB
testcase_18 AC 110 ms
38,564 KB
testcase_19 AC 129 ms
38,436 KB
testcase_20 AC 110 ms
41,252 KB
testcase_21 AC 117 ms
38,436 KB
testcase_22 AC 110 ms
38,688 KB
testcase_23 AC 111 ms
41,252 KB
testcase_24 AC 115 ms
41,252 KB
testcase_25 AC 109 ms
41,252 KB
testcase_26 AC 109 ms
41,252 KB
testcase_27 AC 110 ms
41,252 KB
testcase_28 AC 109 ms
41,252 KB
testcase_29 AC 109 ms
41,252 KB
testcase_30 AC 110 ms
41,252 KB
testcase_31 AC 109 ms
41,252 KB
testcase_32 AC 109 ms
41,252 KB
testcase_33 AC 116 ms
42,916 KB
testcase_34 AC 320 ms
218,180 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
  復元対象のプロジェクトを決定しています...
  /home/judge/data/code/main.csproj を復元しました (102 ms)。
MSBuild のバージョン 17.7.3+8ec440e68 (.NET)
  main -> /home/judge/data/code/bin/Release/net7.0/main.dll
  main -> /home/judge/data/code/bin/Release/net7.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 long[] NList => ReadLine().Split().Select(long.Parse).ToArray();
    public static void Main()
    {
        Solve();
    }
    static void Solve()
    {
        var t = NN;
        var ans = new long[t];
        for (var u = 0; u < t; ++u)
        {
            var s = ReadLine().Split();
            var n = s[0];
            var m = int.Parse(s[1]);
            var b0 = n.Select(i => i - '0').ToList();
            var b1 = b0.ToList();
            Increment(b1);
            if (b0[^1] % 2 == 0) Half(b0);
            else Half(b1);
            var b0m = 0L;
            for (var i = 0; i < b0.Count; ++i) b0m = (b0m * 10 + b0[i]) % m;
            var b1m = 0L;
            for (var i = 0; i < b1.Count; ++i) b1m = (b1m * 10 + b1[i]) % m;
            ans[u] = b0m * b1m % m;
        }
        WriteLine(string.Join("\n", ans));
    }
    static void Increment(List<int> b)
    {
        for (var i = b.Count - 1; i >= 0; --i)
        {
            b[i] = (b[i] + 1) % 10;
            if (b[i] != 0) break;
        }
        if (b[0] == 0) b.Insert(0, 1);
    }
    static void Half(List<int> b)
    {
        var take = 0;
        for (var i = 0; i < b.Count; ++i)
        {
            if ((b[i] + take * 10) % 2 == 1)
            {
                b[i] = (b[i] + take * 10) / 2;
                take = 1;
            }
            else
            {
                b[i] = (b[i] + take * 10) / 2;
                take = 0;
            }
        }
    }
}
0