結果
問題 | No.1085 桁和の桁和 |
ユーザー | FF256grhy |
提出日時 | 2020-06-21 19:03:44 |
言語 | C++17 (gcc 12.3.0 + boost 1.83.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 4,184 bytes |
コンパイル時間 | 2,478 ms |
コンパイル使用メモリ | 205,440 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-07-23 00:45:41 |
合計ジャッジ時間 | 4,061 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 2 ms
5,248 KB |
testcase_01 | AC | 2 ms
5,376 KB |
testcase_02 | AC | 1 ms
5,376 KB |
testcase_03 | AC | 2 ms
5,376 KB |
testcase_04 | AC | 5 ms
5,376 KB |
testcase_05 | AC | 2 ms
5,376 KB |
testcase_06 | AC | 2 ms
5,376 KB |
testcase_07 | AC | 2 ms
5,376 KB |
testcase_08 | AC | 2 ms
5,376 KB |
testcase_09 | WA | - |
testcase_10 | AC | 2 ms
5,376 KB |
testcase_11 | WA | - |
testcase_12 | WA | - |
testcase_13 | AC | 6 ms
5,376 KB |
testcase_14 | AC | 13 ms
5,376 KB |
testcase_15 | AC | 28 ms
5,376 KB |
testcase_16 | AC | 27 ms
5,376 KB |
testcase_17 | AC | 14 ms
5,376 KB |
testcase_18 | AC | 8 ms
5,376 KB |
testcase_19 | AC | 25 ms
5,376 KB |
testcase_20 | AC | 4 ms
5,376 KB |
testcase_21 | AC | 17 ms
5,376 KB |
testcase_22 | AC | 23 ms
5,376 KB |
testcase_23 | AC | 4 ms
5,376 KB |
testcase_24 | AC | 2 ms
5,376 KB |
testcase_25 | AC | 15 ms
5,376 KB |
testcase_26 | AC | 29 ms
5,376 KB |
testcase_27 | AC | 22 ms
5,376 KB |
testcase_28 | AC | 33 ms
5,376 KB |
testcase_29 | AC | 18 ms
5,376 KB |
testcase_30 | AC | 16 ms
5,376 KB |
testcase_31 | AC | 27 ms
5,376 KB |
testcase_32 | AC | 19 ms
5,376 KB |
testcase_33 | AC | 38 ms
5,376 KB |
testcase_34 | AC | 39 ms
5,376 KB |
testcase_35 | AC | 37 ms
5,376 KB |
testcase_36 | AC | 37 ms
5,376 KB |
testcase_37 | AC | 38 ms
5,376 KB |
testcase_38 | AC | 38 ms
5,376 KB |
ソースコード
#include <bits/stdc++.h> using namespace std; using LL = long long int; #define incID(i, l, r) for(int i = (l) ; i < (r); ++i) #define decID(i, l, r) for(int i = (r) - 1; i >= (l); --i) #define incII(i, l, r) for(int i = (l) ; i <= (r); ++i) #define decII(i, l, r) for(int i = (r) ; i >= (l); --i) #define inc(i, n) incID(i, 0, n) #define dec(i, n) decID(i, 0, n) #define inc1(i, n) incII(i, 1, n) #define dec1(i, n) decII(i, 1, n) #define inID(v, l, r) ((l) <= (v) && (v) < (r)) #define inII(v, l, r) ((l) <= (v) && (v) <= (r)) #define PB push_back #define EB emplace_back #define MP make_pair #define MT make_tuple #define FI first #define SE second #define FR front() #define BA back() #define ALL(v) v.begin(), v.end() #define RALL(v) v.rbegin(), v.rend() auto setmin = [](auto & a, auto b) { return (b < a ? a = b, true : false); }; auto setmax = [](auto & a, auto b) { return (b > a ? a = b, true : false); }; auto setmineq = [](auto & a, auto b) { return (b <= a ? a = b, true : false); }; auto setmaxeq = [](auto & a, auto b) { return (b >= a ? a = b, true : false); }; #define SI(v) static_cast<int>(v.size()) #define RF(e, v) for(auto & e: v) #define until(e) while(! (e)) #define if_not(e) if(! (e)) #define ef else if #define UR assert(false) #define IN(T, ...) T __VA_ARGS__; IN_(__VA_ARGS__); void IN_() { }; template<typename T, typename ... U> void IN_(T & a, U & ... b) { cin >> a; IN_(b ...); }; template<typename T > void OUT(T && a ) { cout << a << endl; } template<typename T, typename ... U> void OUT(T && a, U && ... b) { cout << a << " "; OUT(b ...); } // ---- ---- template<LL M> class ModInt { private: LL v; pair<LL, LL> ext_gcd(LL a, LL b) { if(b == 0) { assert(a == 1); return { 1, 0 }; } auto p = ext_gcd(b, a % b); return { p.SE, p.FI - (a / b) * p.SE }; } public: ModInt(LL vv = 0) { v = vv; if(abs(v) >= M) { v %= M; } if(v < 0) { v += M; } } LL get_v() { return v; } ModInt inv() { return ext_gcd(M, v).SE; } ModInt exp(LL b) { ModInt p = 1, a = v; if(b < 0) { a = a.inv(); b = -b; } while(b) { if(b & 1) { p *= a; } a *= a; b >>= 1; } return p; } friend bool operator< (ModInt a, ModInt b) { return (a.v < b.v); } friend bool operator> (ModInt a, ModInt b) { return (a.v > b.v); } friend bool operator<=(ModInt a, ModInt b) { return (a.v <= b.v); } friend bool operator>=(ModInt a, ModInt b) { return (a.v >= b.v); } friend bool operator==(ModInt a, ModInt b) { return (a.v == b.v); } friend bool operator!=(ModInt a, ModInt b) { return (a.v != b.v); } friend ModInt operator+ (ModInt a ) { return ModInt(+a.v); } friend ModInt operator- (ModInt a ) { return ModInt(-a.v); } friend ModInt operator+ (ModInt a, ModInt b) { return ModInt(a.v + b.v); } friend ModInt operator- (ModInt a, ModInt b) { return ModInt(a.v - b.v); } friend ModInt operator* (ModInt a, ModInt b) { return ModInt(a.v * b.v); } friend ModInt operator/ (ModInt a, ModInt b) { return a * b.inv(); } friend ModInt operator^ (ModInt a, LL b) { return a.exp(b); } friend ModInt & operator+=(ModInt & a, ModInt b) { return (a = a + b); } friend ModInt & operator-=(ModInt & a, ModInt b) { return (a = a - b); } friend ModInt & operator*=(ModInt & a, ModInt b) { return (a = a * b); } friend ModInt & operator/=(ModInt & a, ModInt b) { return (a = a / b); } friend ModInt & operator^=(ModInt & a, LL b) { return (a = a ^ b); } friend istream & operator>>(istream & s, ModInt & b) { s >> b.v; b = ModInt(b.v); return s; } friend ostream & operator<<(ostream & s, ModInt b) { return (s << b.v); } }; // ---- using MI = ModInt<1'000'000'007>; int main() { IN(string, t); IN(int, D); int n = SI(t); if(D == 0) { RF(c, t) { if_not(c == '0' || c == '?') { OUT(0); exit(0); } } OUT(1); exit(0); } vector<MI> dp(9); dp[0] = 1; inc(i, n) { vector<MI> dp2(9); inc(j, 9) { inc(k, 10) { if_not(t[i] == '?' || k == t[i] - '0') { continue; } dp2[(j + k) % 9] += dp[j]; } } dp = dp2; } OUT(dp[D % 9]); }