結果

問題 No.741 AscNumber(Easy)
ユーザー peroon
提出日時 2019-04-25 06:58:50
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 178 ms / 2,000 ms
コード長 934 bytes
コンパイル時間 1,609 ms
コンパイル使用メモリ 166,152 KB
実行使用メモリ 81,536 KB
最終ジャッジ日時 2024-11-17 11:09:59
合計ジャッジ時間 4,945 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 55
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
using ll = long long;

#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define ALL(v) (v).begin(), (v).end()
#define p(s) cout<<(s)<<endl
#define p2(s, t) cout << (s) << " " << (t) << endl
#define br() p("")
#define pn(s) cout << (#s) << " " << (s) << endl
#define p_yes() p("Yes")
#define p_no() p("No")

const ll mod = 1e9 + 7;
const ll inf = 1e18;

// dp[i][j]
// i 桁まで確定
// j 最下位桁の値 (leftmost)
ll dp[1000010][10];

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);

    // input
    ll N;
    cin >> N;

    FOR(i, 0, 10){
        dp[1][i] = 1;
    }

    FOR(i, 1, N){
        FOR(lst, 0, 10){
            FOR(nxt, lst, 10){
                dp[i+1][nxt] += dp[i][lst];
                dp[i+1][nxt] %= mod;
            }
        }
    }

    ll sum = 0;
    FOR(i, 0, 10){
        sum += dp[N][i];
        sum %= mod;
    }

    p(sum);
    
    return 0;
}
0