結果

問題 No.1085 桁和の桁和
ユーザー kotatsugamekotatsugame
提出日時 2020-06-19 21:52:17
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 499 bytes
コンパイル時間 453 ms
コンパイル使用メモリ 64,624 KB
実行使用メモリ 10,580 KB
最終ジャッジ日時 2023-09-30 06:03:54
合計ジャッジ時間 1,974 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 2 ms
4,380 KB
testcase_04 WA -
testcase_05 WA -
testcase_06 AC 2 ms
4,376 KB
testcase_07 AC 1 ms
4,380 KB
testcase_08 AC 1 ms
4,380 KB
testcase_09 WA -
testcase_10 AC 1 ms
4,376 KB
testcase_11 WA -
testcase_12 WA -
testcase_13 AC 3 ms
4,380 KB
testcase_14 AC 7 ms
6,052 KB
testcase_15 AC 16 ms
9,496 KB
testcase_16 AC 16 ms
9,456 KB
testcase_17 AC 8 ms
6,232 KB
testcase_18 AC 5 ms
4,856 KB
testcase_19 AC 14 ms
8,824 KB
testcase_20 AC 3 ms
4,380 KB
testcase_21 AC 10 ms
6,892 KB
testcase_22 AC 13 ms
8,420 KB
testcase_23 AC 3 ms
4,376 KB
testcase_24 AC 2 ms
4,380 KB
testcase_25 AC 9 ms
6,684 KB
testcase_26 AC 16 ms
9,728 KB
testcase_27 AC 14 ms
8,416 KB
testcase_28 AC 18 ms
10,516 KB
testcase_29 AC 11 ms
7,232 KB
testcase_30 AC 10 ms
6,864 KB
testcase_31 AC 15 ms
9,516 KB
testcase_32 AC 11 ms
7,624 KB
testcase_33 AC 23 ms
10,548 KB
testcase_34 AC 22 ms
10,536 KB
testcase_35 AC 24 ms
10,528 KB
testcase_36 AC 25 ms
10,544 KB
testcase_37 AC 24 ms
10,580 KB
testcase_38 AC 22 ms
10,536 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];
main()
{
	cin>>T>>D;
	if(D==0)
	{
		if(T=="0"||T=="?")cout<<1<<endl;
		else cout<<0<<endl;
		return 0;
	}
	D%=9;
	dp[0][0]=1;
	for(int i=0;i<T.size();i++)
	{
		for(int j=0;j<9;j++)
		{
			if(T[i]=='?')
			{
				(dp[i+1][j]+=dp[i][j])%=mod;
				for(int k=0;k<9;k++)(dp[i+1][k]+=dp[i][j])%=mod;
			}
			else
			{
				(dp[i+1][(j+T[i]-'0')%9]+=dp[i][j])%=mod;
			}
		}
	}
	cout<<dp[T.size()][D]<<endl;
}
0