結果

問題 No.1620 Substring Sum
ユーザー 👑 kakel-sankakel-san
提出日時 2021-07-22 22:35:09
言語 C#(csc)
(csc 3.9.0)
結果
AC  
実行時間 76 ms / 2,000 ms
コード長 934 bytes
コンパイル時間 1,490 ms
コンパイル使用メモリ 67,940 KB
実行使用メモリ 25,600 KB
最終ジャッジ日時 2023-09-24 17:56:00
合計ジャッジ時間 4,149 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 55 ms
21,480 KB
testcase_01 AC 56 ms
21,628 KB
testcase_02 AC 56 ms
21,548 KB
testcase_03 AC 55 ms
21,544 KB
testcase_04 AC 72 ms
23,528 KB
testcase_05 AC 76 ms
23,568 KB
testcase_06 AC 72 ms
23,552 KB
testcase_07 AC 73 ms
23,680 KB
testcase_08 AC 73 ms
21,556 KB
testcase_09 AC 72 ms
23,492 KB
testcase_10 AC 73 ms
23,508 KB
testcase_11 AC 74 ms
23,580 KB
testcase_12 AC 62 ms
23,704 KB
testcase_13 AC 73 ms
23,340 KB
testcase_14 AC 73 ms
23,584 KB
testcase_15 AC 73 ms
25,312 KB
testcase_16 AC 68 ms
22,380 KB
testcase_17 AC 71 ms
23,220 KB
testcase_18 AC 55 ms
23,532 KB
testcase_19 AC 56 ms
19,516 KB
testcase_20 AC 73 ms
25,600 KB
testcase_21 AC 72 ms
23,616 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

class yuki1
{
    static int NN => int.Parse(ReadLine());
    static int[] NList => ReadLine().Split().Select(int.Parse).ToArray();
    static void Main()
    {
        var s = ReadLine().Select(c => c - '0').ToArray();

        var key = 998244353;
        var res = 0L;
        var mul = Exp(2, s.Length - 1, key);
        var half = Exp(2, key - 2, key);
        for (var i = s.Length - 1; i >= 0; --i)
        {
            res = (res + s[i] * mul % key) % key;
            mul = (mul * 11 % key) * half % key;
        }
        WriteLine(res);
    }
    static long Exp(int n, int k, int keyNum)
    {
        if (k == 0) return 1;
        if (k == 1) return n % keyNum;
        var half = Exp(n, k / 2, keyNum);
        var result = (half * half) % keyNum;
        return ((k % 2) == 0) ? result : ((result * n) % keyNum);
    }
}
0