結果
| 問題 |
No.1085 桁和の桁和
|
| コンテスト | |
| ユーザー |
hirokazu1020
|
| 提出日時 | 2020-06-19 22:56:18 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
AC
|
| 実行時間 | 27 ms / 2,000 ms |
| コード長 | 1,043 bytes |
| コンパイル時間 | 1,082 ms |
| コンパイル使用メモリ | 95,752 KB |
| 実行使用メモリ | 7,040 KB |
| 最終ジャッジ日時 | 2024-11-06 17:39:19 |
| 合計ジャッジ時間 | 2,496 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 35 |
ソースコード
#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<sstream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<climits>
#include<cmath>
#include<string>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<numeric>
#include<functional>
#include<algorithm>
#include<bitset>
#include<tuple>
#include<unordered_set>
#include<unordered_map>
#include<random>
#include<array>
#include<cassert>
using namespace std;
#define INF ((1<<30)-1)
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(v) v.begin(),v.end()
#define MOD 1000000007
int dp[100001][9];
int main() {
ios::sync_with_stdio(0);
cin.tie(0);
string t;
int d;
cin >> t >> d;
int s = 0;
int q = 0;
for (char c : t) {
if (c == '?') {
q++;
}
else {
s += c - '0';
}
}
if (d == 0) {
cout << (s == 0) << endl;
return 0;
}
dp[0][s % 9] = 1;
rep(i, q) {
rep(j,9) {
rep(k, 10) {
(dp[i + 1][(j + k)%9] += dp[i][j]) %= MOD;
}
}
}
cout << dp[q][d % 9] - (s == 0 && d == 9) << endl;
return 0;
}
hirokazu1020