結果

問題 No.741 AscNumber(Easy)
ユーザー 🍮かんプリン🍮かんプリン
提出日時 2019-08-27 01:11:14
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 164 ms / 2,000 ms
コード長 1,581 bytes
コンパイル時間 1,609 ms
コンパイル使用メモリ 168,908 KB
実行使用メモリ 120,536 KB
最終ジャッジ日時 2024-04-26 07:11:14
合計ジャッジ時間 5,174 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,816 KB
testcase_01 AC 2 ms
6,944 KB
testcase_02 AC 2 ms
6,944 KB
testcase_03 AC 2 ms
6,940 KB
testcase_04 AC 2 ms
6,940 KB
testcase_05 AC 2 ms
6,944 KB
testcase_06 AC 2 ms
6,940 KB
testcase_07 AC 1 ms
6,940 KB
testcase_08 AC 2 ms
6,940 KB
testcase_09 AC 2 ms
6,940 KB
testcase_10 AC 2 ms
6,940 KB
testcase_11 AC 2 ms
6,940 KB
testcase_12 AC 2 ms
6,944 KB
testcase_13 AC 2 ms
6,940 KB
testcase_14 AC 1 ms
6,940 KB
testcase_15 AC 2 ms
6,940 KB
testcase_16 AC 1 ms
6,940 KB
testcase_17 AC 2 ms
6,940 KB
testcase_18 AC 2 ms
6,944 KB
testcase_19 AC 2 ms
6,940 KB
testcase_20 AC 1 ms
6,940 KB
testcase_21 AC 2 ms
6,940 KB
testcase_22 AC 2 ms
6,940 KB
testcase_23 AC 2 ms
6,940 KB
testcase_24 AC 2 ms
6,940 KB
testcase_25 AC 1 ms
6,940 KB
testcase_26 AC 1 ms
6,940 KB
testcase_27 AC 2 ms
6,940 KB
testcase_28 AC 2 ms
6,940 KB
testcase_29 AC 1 ms
6,944 KB
testcase_30 AC 2 ms
6,944 KB
testcase_31 AC 2 ms
6,940 KB
testcase_32 AC 1 ms
6,940 KB
testcase_33 AC 2 ms
6,940 KB
testcase_34 AC 2 ms
6,940 KB
testcase_35 AC 156 ms
114,920 KB
testcase_36 AC 70 ms
51,808 KB
testcase_37 AC 81 ms
60,592 KB
testcase_38 AC 83 ms
59,732 KB
testcase_39 AC 69 ms
50,988 KB
testcase_40 AC 97 ms
68,152 KB
testcase_41 AC 149 ms
105,112 KB
testcase_42 AC 82 ms
57,128 KB
testcase_43 AC 60 ms
42,360 KB
testcase_44 AC 114 ms
83,052 KB
testcase_45 AC 124 ms
89,432 KB
testcase_46 AC 151 ms
109,552 KB
testcase_47 AC 29 ms
21,120 KB
testcase_48 AC 148 ms
109,552 KB
testcase_49 AC 125 ms
92,156 KB
testcase_50 AC 19 ms
15,488 KB
testcase_51 AC 59 ms
44,200 KB
testcase_52 AC 164 ms
120,536 KB
testcase_53 AC 160 ms
120,536 KB
testcase_54 AC 164 ms
119,328 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include "bits/stdc++.h"
#define ALL(obj) (obj).begin(),(obj).end()
#define RALL(obj) (obj).rbegin(),(obj).rend()
#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define REPR(i, n) for(int i = (int)(n); i >= 0; i--)
#define FOR(i,n,m) for(int i = (int)(n); i < int(m); i++)
using namespace std;
typedef long long ll;
const int MOD = 1e9 + 7;
const int INF = MOD - 1;
const ll LLINF = 4e18;

struct mint {
private:
    ll x;
public:
    mint(ll x = 0) :x(x%MOD) {}
    mint& operator+=(const mint a) {
        if ((x += a.x) >= MOD) x -= MOD;
        return *this;
    }
    mint& operator-=(const mint a) {
        if ((x += MOD - a.x) >= MOD) x -= MOD;
        return *this;
    }
    mint& operator*=(const mint a) {
        (x *= a.x) %= MOD;
        return *this;
    }
    mint operator+(const mint a) const {
        mint res(*this);
        return res += a;
    }
    mint operator-(const mint a) const {
        mint res(*this);
        return res -= a;
    }
    mint operator*(const mint a) const {
        mint res(*this);
        return res *= a;
    }
    friend ostream& operator<<(ostream& os, const mint& n) {
        return os << n.x;
    }
};

int main() {
    int n; cin >> n;
    // dp[i][j]:前からi番目までで最後の桁がj
    vector<vector<mint>> dp(n+1, vector<mint>(10,0));
    dp[0][0] = 1;
    REP(i, n) {
        REP(j, 10) {
            FOR(k,j,10) {
                dp[i+1][k] += dp[i][j];
            }
        }
    }
    mint ans = 0;
    REP(i, 10) {
        ans += dp[n][i];
    }
    cout << ans << endl;
    getchar(); getchar();
}
0