結果

問題 No.1620 Substring Sum
ユーザー さかぽんさかぽん
提出日時 2021-07-22 22:01:02
言語 C#(csc)
(csc 3.9.0)
結果
AC  
実行時間 60 ms / 2,000 ms
コード長 894 bytes
コンパイル時間 5,100 ms
コンパイル使用メモリ 105,596 KB
実行使用メモリ 22,792 KB
最終ジャッジ日時 2023-09-24 16:56:03
合計ジャッジ時間 6,986 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 51 ms
20,576 KB
testcase_01 AC 52 ms
22,528 KB
testcase_02 AC 51 ms
20,496 KB
testcase_03 AC 52 ms
20,496 KB
testcase_04 AC 59 ms
20,716 KB
testcase_05 AC 58 ms
20,756 KB
testcase_06 AC 57 ms
20,668 KB
testcase_07 AC 57 ms
20,696 KB
testcase_08 AC 58 ms
18,676 KB
testcase_09 AC 58 ms
20,792 KB
testcase_10 AC 60 ms
20,740 KB
testcase_11 AC 58 ms
20,616 KB
testcase_12 AC 53 ms
20,500 KB
testcase_13 AC 57 ms
22,704 KB
testcase_14 AC 58 ms
22,672 KB
testcase_15 AC 57 ms
22,576 KB
testcase_16 AC 54 ms
20,612 KB
testcase_17 AC 57 ms
22,568 KB
testcase_18 AC 51 ms
20,504 KB
testcase_19 AC 49 ms
22,648 KB
testcase_20 AC 57 ms
22,792 KB
testcase_21 AC 57 ms
20,684 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc)
Copyright (C) Microsoft Corporation. All rights reserved.

ソースコード

diff #

using System;
using System.Collections.Generic;
using System.Linq;

class E
{
	static int[] Read() => Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
	static (int, int) Read2() { var a = Read(); return (a[0], a[1]); }
	static long[] ReadL() => Array.ConvertAll(Console.ReadLine().Split(), long.Parse);
	static void Main() => Console.WriteLine(Solve());
	static object Solve()
	{
		var s = Console.ReadLine();
		var n = s.Length;

		var r = 0L;
		var p = MPow(2, n - 1);
		var M11_2 = MHalf * 11 % M;

		for (int i = n - 1; i >= 0; i--)
		{
			var d = s[i] - '0';

			r += p * d;
			r %= M;

			p *= M11_2;
			p %= M;
		}

		return r;
	}

	const long M = 998244353;
	const long MHalf = (M + 1) / 2;
	static long MPow(long b, long i)
	{
		long r = 1;
		for (; i != 0; b = b * b % M, i >>= 1) if ((i & 1) != 0) r = r * b % M;
		return r;
	}
	static long MInv(long x) => MPow(x, M - 2);
}
0