結果

問題 No.741 AscNumber(Easy)
ユーザー momoyuumomoyuu
提出日時 2023-04-01 20:37:12
言語 C++23
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 176 ms / 2,000 ms
コード長 1,933 bytes
コンパイル時間 2,813 ms
コンパイル使用メモリ 249,688 KB
実行使用メモリ 120,340 KB
最終ジャッジ日時 2023-10-24 18:20:54
合計ジャッジ時間 7,487 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,348 KB
testcase_01 AC 2 ms
4,348 KB
testcase_02 AC 1 ms
4,348 KB
testcase_03 AC 1 ms
4,348 KB
testcase_04 AC 2 ms
4,348 KB
testcase_05 AC 2 ms
4,348 KB
testcase_06 AC 2 ms
4,348 KB
testcase_07 AC 2 ms
4,348 KB
testcase_08 AC 1 ms
4,348 KB
testcase_09 AC 1 ms
4,348 KB
testcase_10 AC 2 ms
4,348 KB
testcase_11 AC 2 ms
4,348 KB
testcase_12 AC 2 ms
4,348 KB
testcase_13 AC 2 ms
4,348 KB
testcase_14 AC 2 ms
4,348 KB
testcase_15 AC 2 ms
4,348 KB
testcase_16 AC 2 ms
4,348 KB
testcase_17 AC 2 ms
4,348 KB
testcase_18 AC 1 ms
4,348 KB
testcase_19 AC 1 ms
4,348 KB
testcase_20 AC 1 ms
4,348 KB
testcase_21 AC 2 ms
4,348 KB
testcase_22 AC 2 ms
4,348 KB
testcase_23 AC 2 ms
4,348 KB
testcase_24 AC 1 ms
4,348 KB
testcase_25 AC 2 ms
4,348 KB
testcase_26 AC 2 ms
4,348 KB
testcase_27 AC 2 ms
4,348 KB
testcase_28 AC 2 ms
4,348 KB
testcase_29 AC 2 ms
4,348 KB
testcase_30 AC 2 ms
4,348 KB
testcase_31 AC 1 ms
4,348 KB
testcase_32 AC 2 ms
4,348 KB
testcase_33 AC 2 ms
4,348 KB
testcase_34 AC 2 ms
4,348 KB
testcase_35 AC 168 ms
115,060 KB
testcase_36 AC 75 ms
51,844 KB
testcase_37 AC 86 ms
60,556 KB
testcase_38 AC 85 ms
59,764 KB
testcase_39 AC 73 ms
50,856 KB
testcase_40 AC 98 ms
68,144 KB
testcase_41 AC 152 ms
105,096 KB
testcase_42 AC 82 ms
57,124 KB
testcase_43 AC 59 ms
42,144 KB
testcase_44 AC 119 ms
83,056 KB
testcase_45 AC 129 ms
89,392 KB
testcase_46 AC 160 ms
109,584 KB
testcase_47 AC 29 ms
21,160 KB
testcase_48 AC 160 ms
109,584 KB
testcase_49 AC 136 ms
92,032 KB
testcase_50 AC 20 ms
15,420 KB
testcase_51 AC 61 ms
44,256 KB
testcase_52 AC 175 ms
120,340 KB
testcase_53 AC 176 ms
120,340 KB
testcase_54 AC 175 ms
119,284 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

//const ll mod = 998'244'353;
const ll mod = 1'000'000'007;
//const ll mod = 67'280'421'310'721;
struct mint{
    long long x;
    mint(long long x=0):x((x%mod+mod)%mod){}
    mint operator-() const{
        return mint(-x);
    }
    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;
    }
    mint pow(long long n) const {
        assert(0 <= n);
        mint a = *this, r = 1;
        while (n) {
            if (n & 1) r *= a;
            a *= a;
            n >>= 1;
        }
        return r;
    }
    mint inv() const{
        return pow(mod-2);
    }
    mint& operator/=(const mint& a){
        return (*this)*=a.inv();
    }
    mint operator/(const mint& a) const {
        mint res(*this);
        return res/=a;
    }
    friend ostream& operator<<(ostream& os, const mint& m){
        os << m.x;
        return os;
    }
    bool operator==(const mint& a) const {
        return x == a.x;
    }
    bool operator<(const mint& a) const{
        return x < a.x;
    }
};


int main(){
    int n;
    cin>>n;
    vector<vector<mint> >dp(n+1,vector<mint>(10,0));
    dp[0][0] = 1;
    for(int i = 0;i<n;i++){
        for(int j = 0;j<=9;j++){
            for(int k = j;k<=9;k++){
                dp[i+1][k] += dp[i][j];
            }
        }
    }
    mint ans = 0;
    for(int i = 0;i<=9;i++) ans += dp[n][i];
    cout<<ans<<endl;
}
0