結果

問題 No.741 AscNumber(Easy)
ユーザー 🍮かんプリン
提出日時 2019-08-27 01:11:14
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 193 ms / 2,000 ms
コード長 1,581 bytes
コンパイル時間 1,681 ms
コンパイル使用メモリ 170,328 KB
実行使用メモリ 120,448 KB
最終ジャッジ日時 2024-11-08 20:10:09
合計ジャッジ時間 5,721 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 55
権限があれば一括ダウンロードができます

ソースコード

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