結果
| 問題 | No.1085 桁和の桁和 |
| コンテスト | |
| ユーザー |
QCFium
|
| 提出日時 | 2020-01-09 23:02:51 |
| 言語 | C++14 (gcc 15.2.0 + boost 1.89.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 634 bytes |
| 記録 | |
| コンパイル時間 | 1,907 ms |
| コンパイル使用メモリ | 169,196 KB |
| 実行使用メモリ | 6,944 KB |
| 最終ジャッジ日時 | 2024-07-22 23:59:08 |
| 合計ジャッジ時間 | 2,679 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 32 WA * 3 |
ソースコード
#include <bits/stdc++.h>
int ri() {
int n;
scanf("%d", &n);
return n;
}
int main() {
std::string s;
std::cin >> s;
int n = s.size();
int d = ri();
if (d == 0) {
puts(std::count_if(s.begin(), s.end(), [] (char c) { return c != '?' && c != '0'; }) ? "0" : "1");
return 0;
}
if (d == 9) d = 0;
int base = 0, res = 0, cur = 1;
for (auto c : s) {
if (c != '?') base += c - '0';
else {
res += cur;
if (res >= 1000000007) res -= 1000000007;
cur = (int64_t) cur * 10 % 1000000007;
}
}
base %= 9;
if (base == d) {
res++;
if (res >= 1000000007) res -= 1000000007;
}
printf("%d\n", res);
return 0;
}
QCFium