結果

問題 No.1407 Kindness
ユーザー HaaHaa
提出日時 2021-02-26 21:44:10
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
RE  
実行時間 -
コード長 1,262 bytes
コンパイル時間 1,317 ms
コンパイル使用メモリ 166,200 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-04-10 12:20:28
合計ジャッジ時間 4,403 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,816 KB
testcase_01 AC 2 ms
6,940 KB
testcase_02 AC 3 ms
6,944 KB
testcase_03 AC 3 ms
6,940 KB
testcase_04 AC 2 ms
6,944 KB
testcase_05 AC 2 ms
6,940 KB
testcase_06 AC 3 ms
6,940 KB
testcase_07 AC 2 ms
6,940 KB
testcase_08 AC 2 ms
6,940 KB
testcase_09 AC 3 ms
6,944 KB
testcase_10 AC 2 ms
6,940 KB
testcase_11 AC 3 ms
6,944 KB
testcase_12 RE -
testcase_13 RE -
testcase_14 RE -
testcase_15 RE -
testcase_16 RE -
testcase_17 RE -
testcase_18 RE -
testcase_19 RE -
testcase_20 RE -
testcase_21 AC 5 ms
6,944 KB
testcase_22 AC 7 ms
6,944 KB
testcase_23 RE -
testcase_24 RE -
testcase_25 RE -
testcase_26 RE -
testcase_27 AC 6 ms
6,940 KB
testcase_28 RE -
testcase_29 AC 4 ms
6,940 KB
testcase_30 RE -
testcase_31 RE -
testcase_32 RE -
testcase_33 RE -
testcase_34 RE -
testcase_35 RE -
testcase_36 AC 4 ms
6,940 KB
testcase_37 RE -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> P;
typedef vector<ll> VI;
typedef vector<VI> VVI;
#define REP(i,n) for(ll i=0;i<(n);i++)
#define ALL(v) v.begin(),v.end()
constexpr ll MOD=1000000007;
constexpr ll INF=1e18;

int main(){
    string s; cin >> s;
    int n=s.size();
    ll dp[2][10101][10]={0};
    REP(i,n-1)
        dp[1][i+1][0]=1;
    dp[0][0][0]=1;
    REP(i,n){
        REP(k,10){
            if(k<s[i]-'0'){
                REP(j,10){
                    dp[1][i+1][k]+=k*dp[1][i][j]%MOD;
                    dp[1][i+1][k]+=k*dp[0][i][j]%MOD;
                    dp[1][i+1][k]%=MOD;
                }
            }
            else if(k==s[i]-'0'){
                REP(j,10){
                    dp[0][i+1][k]+=k*dp[0][i][j]%MOD;
                    dp[0][i+1][k]%=MOD;
                    dp[1][i+1][k]+=k*dp[1][i][j]%MOD;
                    dp[1][i+1][k]%=MOD;
                }
            }
            else{
                REP(j,10){
                    dp[1][i+1][k]+=k*dp[1][i][j]%MOD;
                    dp[1][i+1][k]%=MOD;
                }
            }
        }
    }
    ll ans=0;
    REP(i,10)
        ans+=dp[1][n][i];
    ans+=dp[0][n][s[n-1]-'0'];
    cout << ans%MOD << endl;
}
0