結果
| 問題 |
No.1085 桁和の桁和
|
| コンテスト | |
| ユーザー |
merom686
|
| 提出日時 | 2020-06-19 22:26:27 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,109 bytes |
| コンパイル時間 | 1,026 ms |
| コンパイル使用メモリ | 90,416 KB |
| 最終ジャッジ日時 | 2025-01-11 07:00:01 |
|
ジャッジサーバーID (参考情報) |
judge1 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 32 WA * 3 |
ソースコード
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;
using ll = long long;
constexpr int P = 1000000007;
int main() {
ios::sync_with_stdio(false);
cin.tie(0);
string t;
cin >> t;
int n = t.size();
for (int i = 0; i < n; i++) {
t[i] = t[i] == '?' ? -1 : t[i] - '0';
}
int d;
cin >> d;
if (d == 0) {
for (int i = 0; i < n; i++) {
if (t[i] > 0) {
cout << 0 << endl;
exit(0);
}
}
cout << 1 << endl;
exit(0);
}
int k = 0;
for (int i = 0; i < n; i++) {
if (t[i] < 0) {
k++;
} else {
d -= t[i];
}
}
d %= 9;
d += 9;
d %= 9;
ll dp[9] = { 1 };
for (int i = 0; i < k; i++) {
ll s = 0;
for (int j = 0; j < 9; j++) {
s += dp[j];
}
for (int j = 0; j < 9; j++) {
(dp[j] += s) %= P;
}
}
cout << dp[d] << endl;
return 0;
}
merom686