結果
問題 |
No.1085 桁和の桁和
|
ユーザー |
![]() |
提出日時 | 2020-06-19 21:52:55 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 670 bytes |
コンパイル時間 | 229 ms |
コンパイル使用メモリ | 26,880 KB |
最終ジャッジ日時 | 2025-01-11 06:08:21 |
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 10 WA * 25 |
コンパイルメッセージ
main.cpp: In function ‘int main()’: main.cpp:7:15: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 7 | scanf ("%s %d", S, &D); | ~~~~~~^~~~~~~~~~~~~~~~
ソースコード
#include <stdio.h> char S[100100]; int D; long long C[9] = { 1, }, P[9]; int main() { scanf ("%s %d", S, &D); if (D == 0){ bool g = 1; for (int i = 0; S[i]; i++){ if (S[i] == '?' || S[i] == '0'); else g = 0; } puts(g ? "1" : "0"); return 0; } int s = 0; const long long mod = 1000000007; for (int i = 0; S[i]; i++){ if (S[i] == '?'){ for (int j = 0; j < 9; j++) P[j] = 0; for (int j = 0; j < 9; j++) for (int k = 0; k < 10; k++){ P[(j + k) % 9] = (P[(j + k) % 9] + C[j]) % mod; } for (int j = 0; j < 9; j++) C[j] = P[j]; } else s += S[i] - '0'; } if (D == 9) D = 0; printf ("%lld\n", C[(D + 9 - s) % 9]); return 0; }