結果

問題 No.189 SUPER HAPPY DAY
ユーザー yui_cute__yui_cute__
提出日時 2020-06-10 18:49:47
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,364 bytes
コンパイル時間 1,887 ms
コンパイル使用メモリ 173,956 KB
実行使用メモリ 9,748 KB
最終ジャッジ日時 2023-09-05 16:45:33
合計ジャッジ時間 3,662 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 WA -
testcase_02 AC 2 ms
4,380 KB
testcase_03 WA -
testcase_04 AC 4 ms
4,380 KB
testcase_05 WA -
testcase_06 AC 3 ms
4,376 KB
testcase_07 WA -
testcase_08 AC 3 ms
4,380 KB
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 AC 29 ms
9,748 KB
testcase_24 AC 28 ms
9,692 KB
testcase_25 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#include <unistd.h>
using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7/*998244353*/;
const ll INF = 1LL << 60;
ll mod_pow(ll, ll, ll); ll mod_fact(ll, ll); ll mod_inv(ll, ll); ll gcd(ll, ll); ll lcm(ll, ll);
//
vector<ll> fun(string s){
    vector<vector<vector<ll>>> dp(s.size() + 1, vector<vector<ll>>(2, vector<ll>(2000)));
    dp[0][0][0] = 1;
    for(int i = 0; i < s.size(); i++){
        int d = s[i] - '0';
        for(int j = 0; j < 2; j++){
            for(int k = 0; k < 1900; k++){
                for(int n = 0; n <= (j ? 9 : d); n++){
                    dp[i + 1][j || (n < d)][k + n] = (dp[i + 1][j || (n < d)][k + n] + dp[i][j][k]) % MOD;
                }
            }
        }
    }
    /*for(int i = 0; i <= s.size(); i++){
        cout << "\n";
        for(int j = 0; j < 2; j++){
            cout << "\n";
            for(int k = 0; k < 60; k++){
                cout << dp[i][j][k] << " ";
            }
        }
    }*/
    vector<ll> ret(2000);
    for(int i = 0; i < 2000; i++){
        ret[i] = (dp[s.size()][0][i] + dp[s.size()][1][i]) % MOD;
    }
    return ret;
}
int main(){
    string s, t;
    cin >> s >> t;
    ll ans = 0;
    vector<ll> a = fun(s);
    vector<ll> b = fun(t);
    for(int i = 1; i < 2000; i++){
        ans = (ans + a[i] * b[i]) % MOD;
    }
    cout << ans << "\n";
}
0