結果

問題 No.1620 Substring Sum
ユーザー merlinmerlin
提出日時 2021-07-23 03:16:22
言語 Java21
(openjdk 21)
結果
AC  
実行時間 118 ms / 2,000 ms
コード長 653 bytes
コンパイル時間 1,941 ms
コンパイル使用メモリ 72,012 KB
実行使用メモリ 54,984 KB
最終ジャッジ日時 2023-09-25 00:13:55
合計ジャッジ時間 5,244 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 40 ms
49,136 KB
testcase_01 AC 40 ms
49,228 KB
testcase_02 AC 40 ms
49,132 KB
testcase_03 AC 40 ms
49,676 KB
testcase_04 AC 118 ms
54,744 KB
testcase_05 AC 118 ms
54,548 KB
testcase_06 AC 115 ms
54,636 KB
testcase_07 AC 107 ms
54,868 KB
testcase_08 AC 115 ms
54,768 KB
testcase_09 AC 115 ms
54,672 KB
testcase_10 AC 118 ms
54,452 KB
testcase_11 AC 117 ms
54,984 KB
testcase_12 AC 63 ms
51,592 KB
testcase_13 AC 112 ms
54,616 KB
testcase_14 AC 106 ms
54,752 KB
testcase_15 AC 98 ms
53,940 KB
testcase_16 AC 85 ms
54,148 KB
testcase_17 AC 92 ms
54,012 KB
testcase_18 AC 40 ms
49,176 KB
testcase_19 AC 40 ms
49,244 KB
testcase_20 AC 117 ms
52,728 KB
testcase_21 AC 115 ms
54,604 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.io.*;
import java.util.*;

class Main
{
    public static void main(String args[])throws Exception
    {
        BufferedReader bu=new BufferedReader(new InputStreamReader(System.in));
        StringBuilder sb=new StringBuilder();
        char s[]=bu.readLine().toCharArray();

        int n=s.length,i; long p2[]=new long[n+1],p11[]=new long[n+1],M=998244353;
        p2[0]=1; p11[0]=1;
        for(i=1;i<=n;i++)
        {
            p2[i]=p2[i-1]*2%M;
            p11[i]=p11[i-1]*11%M;
        }

        long ans=0;
        for(i=0;i<n;i++)
        ans=(ans+1l*p2[i]*p11[n-i-1]%M*(s[i]-'0')%M)%M;
        System.out.println(ans);
    }
}
0