結果
| 問題 |
No.1085 桁和の桁和
|
| コンテスト | |
| ユーザー |
milanis48663220
|
| 提出日時 | 2020-06-19 23:02:31 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
RE
|
| 実行時間 | - |
| コード長 | 1,087 bytes |
| コンパイル時間 | 1,252 ms |
| コンパイル使用メモリ | 83,392 KB |
| 実行使用メモリ | 11,520 KB |
| 最終ジャッジ日時 | 2024-07-23 00:38:12 |
| 合計ジャッジ時間 | 3,323 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 RE * 1 |
| other | AC * 27 WA * 3 RE * 5 |
ソースコード
#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 -1;
}
}
cout << 1 << endl;
return -1;
}
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;
}
}
}
cout << dp[N][D%9] << endl;
}
milanis48663220