結果

問題 No.1407 Kindness
ユーザー ks2mks2m
提出日時 2021-02-26 23:07:22
言語 Java21
(openjdk 21)
結果
AC  
実行時間 181 ms / 2,000 ms
コード長 642 bytes
コンパイル時間 1,685 ms
コンパイル使用メモリ 74,608 KB
実行使用メモリ 56,724 KB
最終ジャッジ日時 2024-04-10 14:07:46
合計ジャッジ時間 7,690 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 104 ms
53,996 KB
testcase_01 AC 103 ms
53,928 KB
testcase_02 AC 101 ms
54,260 KB
testcase_03 AC 102 ms
53,980 KB
testcase_04 AC 92 ms
52,912 KB
testcase_05 AC 99 ms
53,420 KB
testcase_06 AC 113 ms
54,036 KB
testcase_07 AC 107 ms
53,880 KB
testcase_08 AC 102 ms
54,148 KB
testcase_09 AC 103 ms
54,116 KB
testcase_10 AC 104 ms
54,036 KB
testcase_11 AC 102 ms
54,112 KB
testcase_12 AC 173 ms
56,724 KB
testcase_13 AC 112 ms
52,880 KB
testcase_14 AC 125 ms
53,828 KB
testcase_15 AC 181 ms
56,472 KB
testcase_16 AC 140 ms
54,292 KB
testcase_17 AC 131 ms
53,868 KB
testcase_18 AC 128 ms
54,388 KB
testcase_19 AC 177 ms
56,272 KB
testcase_20 AC 171 ms
56,600 KB
testcase_21 AC 122 ms
54,008 KB
testcase_22 AC 124 ms
54,428 KB
testcase_23 AC 148 ms
56,004 KB
testcase_24 AC 175 ms
56,432 KB
testcase_25 AC 129 ms
53,736 KB
testcase_26 AC 151 ms
54,728 KB
testcase_27 AC 103 ms
54,408 KB
testcase_28 AC 179 ms
56,316 KB
testcase_29 AC 111 ms
54,052 KB
testcase_30 AC 172 ms
56,524 KB
testcase_31 AC 114 ms
53,132 KB
testcase_32 AC 164 ms
56,440 KB
testcase_33 AC 127 ms
54,184 KB
testcase_34 AC 149 ms
56,416 KB
testcase_35 AC 124 ms
54,260 KB
testcase_36 AC 120 ms
54,276 KB
testcase_37 AC 177 ms
56,292 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		char[] s = sc.next().toCharArray();
		sc.close();

		int n = s.length;
		int mod = 1000000007;
		long[] dp0 = new long[n + 1];
		long[] dp1 = new long[n + 1];
		dp0[0] = 1;
		for (int i = 0; i < n; i++) {
			int d = s[i] - '0';
			dp1[i + 1] += dp1[i] * 45;
			if (i > 0) {
				dp1[i + 1] += 45;
			}
			if (d > 0) {
				dp1[i + 1] += dp0[i] * (d - 1) * d / 2;
				dp0[i + 1] = dp0[i] * d;
			}
			dp1[i + 1] %= mod;
			dp0[i + 1] %= mod;
		}
		System.out.println((dp1[n] + dp0[n]) % mod);
	}
}
0