結果

問題 No.741 AscNumber(Easy)
ユーザー kura197kura197
提出日時 2021-07-06 11:14:15
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 348 ms / 2,000 ms
コード長 1,403 bytes
コンパイル時間 1,830 ms
コンパイル使用メモリ 199,160 KB
実行使用メモリ 175,380 KB
最終ジャッジ日時 2023-09-14 04:20:42
合計ジャッジ時間 8,145 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 1 ms
4,376 KB
testcase_04 AC 1 ms
4,380 KB
testcase_05 AC 1 ms
4,376 KB
testcase_06 AC 1 ms
4,376 KB
testcase_07 AC 1 ms
4,380 KB
testcase_08 AC 1 ms
4,380 KB
testcase_09 AC 1 ms
4,380 KB
testcase_10 AC 1 ms
4,380 KB
testcase_11 AC 2 ms
4,380 KB
testcase_12 AC 2 ms
4,376 KB
testcase_13 AC 2 ms
4,380 KB
testcase_14 AC 1 ms
4,376 KB
testcase_15 AC 1 ms
4,376 KB
testcase_16 AC 2 ms
4,376 KB
testcase_17 AC 1 ms
4,376 KB
testcase_18 AC 1 ms
4,376 KB
testcase_19 AC 1 ms
4,376 KB
testcase_20 AC 1 ms
4,376 KB
testcase_21 AC 1 ms
4,380 KB
testcase_22 AC 2 ms
4,376 KB
testcase_23 AC 2 ms
4,376 KB
testcase_24 AC 1 ms
4,376 KB
testcase_25 AC 1 ms
4,376 KB
testcase_26 AC 2 ms
4,380 KB
testcase_27 AC 1 ms
4,376 KB
testcase_28 AC 1 ms
4,380 KB
testcase_29 AC 1 ms
4,376 KB
testcase_30 AC 2 ms
4,376 KB
testcase_31 AC 2 ms
4,380 KB
testcase_32 AC 1 ms
4,376 KB
testcase_33 AC 1 ms
4,376 KB
testcase_34 AC 2 ms
4,376 KB
testcase_35 AC 330 ms
167,200 KB
testcase_36 AC 146 ms
74,760 KB
testcase_37 AC 171 ms
87,384 KB
testcase_38 AC 168 ms
86,372 KB
testcase_39 AC 143 ms
73,360 KB
testcase_40 AC 193 ms
98,464 KB
testcase_41 AC 300 ms
152,960 KB
testcase_42 AC 161 ms
82,524 KB
testcase_43 AC 117 ms
60,808 KB
testcase_44 AC 235 ms
120,352 KB
testcase_45 AC 254 ms
129,544 KB
testcase_46 AC 312 ms
159,228 KB
testcase_47 AC 56 ms
29,712 KB
testcase_48 AC 314 ms
159,244 KB
testcase_49 AC 262 ms
133,520 KB
testcase_50 AC 39 ms
21,160 KB
testcase_51 AC 123 ms
63,512 KB
testcase_52 AC 347 ms
175,344 KB
testcase_53 AC 348 ms
175,380 KB
testcase_54 AC 341 ms
173,500 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
#define REP(i, n) for(int i=0; i<n; i++)
#define REPi(i, a, b) for(int i=int(a); i<int(b); i++)
#define MEMS(a,b) memset(a,b,sizeof(a))
#define mp make_pair
#define MOD(a, m) ((a % m + m) % m)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const ll MOD = 1e9+7;

/// {keta, last-num, small}
ll DP[1000100][11][2];

int main(){
    ll N;
    cin >> N;

    DP[0][0][0] = 1;
    REP(i,N+1){
        //int n = S[i] - '0';
        int n = (i == 0);
        for(int last = 0; last < 10; last++){
            for(int s = 0; s < 2; s++){
                for(int j = 0; j < 10; j++){
                    int nl = -1, ns = -1;

                    if(!s && j > n) continue;

                    if(j < n) ns = 1;
                    else ns = s;

                    if(j < last) continue;

                    nl = j;

                    DP[i+1][nl][ns] += DP[i][last][s];
                    DP[i+1][nl][ns] %= MOD;
                }
            }
        }
    }

    ll ans = 0;
    for(int last = 0; last < 10; last++){
        for(int s = 0; s < 2; s++){
            ans += DP[N+1][last][s];
            ans %= MOD;
        }
    }

    cout << ans << endl;
    return 0;
}
0