結果

問題 No.1085 桁和の桁和
ユーザー kotatsugamekotatsugame
提出日時 2020-06-19 21:55:16
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 69 ms / 2,000 ms
コード長 514 bytes
コンパイル時間 553 ms
コンパイル使用メモリ 65,104 KB
実行使用メモリ 17,680 KB
最終ジャッジ日時 2023-08-06 14:28:31
合計ジャッジ時間 2,843 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 1 ms
4,380 KB
testcase_04 AC 66 ms
17,052 KB
testcase_05 AC 2 ms
4,380 KB
testcase_06 AC 1 ms
4,376 KB
testcase_07 AC 2 ms
4,380 KB
testcase_08 AC 1 ms
4,376 KB
testcase_09 AC 1 ms
4,380 KB
testcase_10 AC 2 ms
4,380 KB
testcase_11 AC 2 ms
4,380 KB
testcase_12 AC 2 ms
4,376 KB
testcase_13 AC 7 ms
4,992 KB
testcase_14 AC 19 ms
8,644 KB
testcase_15 AC 41 ms
15,448 KB
testcase_16 AC 40 ms
15,368 KB
testcase_17 AC 20 ms
8,980 KB
testcase_18 AC 11 ms
6,364 KB
testcase_19 AC 36 ms
14,160 KB
testcase_20 AC 37 ms
14,192 KB
testcase_21 AC 24 ms
10,220 KB
testcase_22 AC 34 ms
13,260 KB
testcase_23 AC 4 ms
4,492 KB
testcase_24 AC 3 ms
4,376 KB
testcase_25 AC 22 ms
9,456 KB
testcase_26 AC 42 ms
15,824 KB
testcase_27 AC 34 ms
13,376 KB
testcase_28 AC 47 ms
17,512 KB
testcase_29 AC 26 ms
10,844 KB
testcase_30 AC 24 ms
10,192 KB
testcase_31 AC 40 ms
15,320 KB
testcase_32 AC 29 ms
11,544 KB
testcase_33 AC 69 ms
17,548 KB
testcase_34 AC 68 ms
17,636 KB
testcase_35 AC 68 ms
17,544 KB
testcase_36 AC 69 ms
17,612 KB
testcase_37 AC 68 ms
17,496 KB
testcase_38 AC 68 ms
17,680 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp:7:1: 警告: ISO C++ では型の無い ‘main’ の宣言を禁止しています [-Wreturn-type]
    7 | main()
      | ^~~~

ソースコード

diff #

#include<iostream>
using namespace std;
const long mod=1e9+7;
string T;
int D;
long dp[1<<17][9][2];
main()
{
	cin>>T>>D;
	dp[0][0][0]=1;
	for(int i=0;i<T.size();i++)
	{
		for(int j=0;j<9;j++)for(int jj=0;jj<2;jj++)
		{
			if(T[i]=='?')
			{
				for(int k=0;k<=9;k++)(dp[i+1][(j+k)%9][jj||k]+=dp[i][j][jj])%=mod;
			}
			else
			{
				if(T[i]=='0')(dp[i+1][j][jj]+=dp[i][j][jj])%=mod;
				else(dp[i+1][(j+T[i]-'0')%9][1]+=dp[i][j][jj])%=mod;
			}
		}
	}
	cout<<(D?dp[T.size()][D%9][1]:dp[T.size()][0][0])<<endl;
}
0