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