結果
| 問題 |
No.1085 桁和の桁和
|
| コンテスト | |
| ユーザー |
milanis48663220
|
| 提出日時 | 2020-06-19 23:04:55 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 35 ms / 2,000 ms |
| コード長 | 1,343 bytes |
| コンパイル時間 | 906 ms |
| コンパイル使用メモリ | 83,908 KB |
| 実行使用メモリ | 11,520 KB |
| 最終ジャッジ日時 | 2024-11-06 17:39:39 |
| 合計ジャッジ時間 | 2,409 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 35 |
ソースコード
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <queue>
#include <set>
#include <map>
using namespace std;
typedef long long ll;
const ll MOD = 1000000007;
ll dp[100001][10];
string T;
int D;
int main(){
ios::sync_with_stdio(false);
cin.tie(0);
cout << setprecision(10) << fixed;
cin >> T >> D;
dp[0][0] = 1;
int N = T.size();
if(D == 0){
for(int i = 0; i < N; i++){
if(T[i] != '0' && T[i] != '?'){
cout << 0 << endl;
return 0;
}
}
cout << 1 << endl;
return 0;
}
for(int i = 0; i < N; i++){
for(int j = 0; j < 9; j++){
if(T[i] == '?'){
for(int k = 0; k < 10; k++){
dp[i+1][(j+k)%9] += dp[i][j];
dp[i+1][(j+k)%9] %= MOD;
}
}else{
int k = T[i]-'0';
dp[i+1][(j+k)%9] += dp[i][j];
dp[i+1][(j+k)%9] %= MOD;
}
}
}
if(D == 9){
for(int i = 0; i < N; i++){
if(T[i] != '0' && T[i] != '?'){
cout << dp[N][0] << endl;
return 0;
}
}
cout << (dp[N][0]+MOD-1)%MOD << endl;
return 0;
}
cout << dp[N][D%9] << endl;
}
milanis48663220