結果

問題 No.741 AscNumber(Easy)
ユーザー hanbei_dayohanbei_dayo
提出日時 2020-08-17 23:59:12
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 343 ms / 2,000 ms
コード長 1,254 bytes
コンパイル時間 914 ms
コンパイル使用メモリ 101,336 KB
実行使用メモリ 159,872 KB
最終ジャッジ日時 2024-04-19 19:19:26
合計ジャッジ時間 6,899 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,816 KB
testcase_01 AC 2 ms
6,812 KB
testcase_02 AC 1 ms
6,812 KB
testcase_03 AC 2 ms
6,820 KB
testcase_04 AC 2 ms
6,940 KB
testcase_05 AC 1 ms
6,940 KB
testcase_06 AC 2 ms
6,944 KB
testcase_07 AC 2 ms
6,940 KB
testcase_08 AC 2 ms
6,944 KB
testcase_09 AC 1 ms
6,944 KB
testcase_10 AC 2 ms
6,940 KB
testcase_11 AC 2 ms
6,940 KB
testcase_12 AC 1 ms
6,944 KB
testcase_13 AC 2 ms
6,940 KB
testcase_14 AC 1 ms
6,944 KB
testcase_15 AC 2 ms
6,940 KB
testcase_16 AC 2 ms
6,940 KB
testcase_17 AC 1 ms
6,940 KB
testcase_18 AC 1 ms
6,940 KB
testcase_19 AC 2 ms
6,940 KB
testcase_20 AC 1 ms
6,944 KB
testcase_21 AC 2 ms
6,944 KB
testcase_22 AC 2 ms
6,944 KB
testcase_23 AC 2 ms
6,944 KB
testcase_24 AC 2 ms
6,940 KB
testcase_25 AC 1 ms
6,940 KB
testcase_26 AC 2 ms
6,940 KB
testcase_27 AC 2 ms
6,944 KB
testcase_28 AC 2 ms
6,940 KB
testcase_29 AC 2 ms
6,944 KB
testcase_30 AC 2 ms
6,940 KB
testcase_31 AC 2 ms
6,940 KB
testcase_32 AC 2 ms
6,940 KB
testcase_33 AC 2 ms
6,940 KB
testcase_34 AC 2 ms
6,940 KB
testcase_35 AC 329 ms
152,576 KB
testcase_36 AC 145 ms
68,480 KB
testcase_37 AC 172 ms
79,872 KB
testcase_38 AC 169 ms
78,848 KB
testcase_39 AC 141 ms
67,200 KB
testcase_40 AC 196 ms
89,984 KB
testcase_41 AC 298 ms
139,520 KB
testcase_42 AC 162 ms
75,520 KB
testcase_43 AC 118 ms
55,680 KB
testcase_44 AC 232 ms
109,824 KB
testcase_45 AC 250 ms
118,272 KB
testcase_46 AC 308 ms
145,408 KB
testcase_47 AC 55 ms
27,392 KB
testcase_48 AC 307 ms
145,152 KB
testcase_49 AC 263 ms
121,856 KB
testcase_50 AC 37 ms
19,584 KB
testcase_51 AC 120 ms
58,112 KB
testcase_52 AC 335 ms
159,872 KB
testcase_53 AC 339 ms
159,744 KB
testcase_54 AC 343 ms
158,464 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<utility>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<functional>
#include<math.h>
#include<random>
#include <bitset>
#include <cassert>
#include <complex>
using namespace std;
#define N (1000000000+7)
//#define N 998244353
#define INF 1e16
typedef long long ll;
typedef pair<int,int> P;
const int inf = 1e8;


ll dp[1000100][2][10];

int main() {
    int n;
    cin>>n;
    dp[0][0][0]=1;
    for(int i=0;i<=n;i++){
        int x = ((i==0)?1:0);
        for(int k=0;k<10;k++){
            for(int l=k;l<10;l++){
                if(l==x)dp[i+1][0][l] = (dp[i+1][0][l]+dp[i][0][k])%N;
                else{
                    dp[i+1][1][l] = (dp[i+1][1][l]+dp[i][0][k])%N;
                }
            }
        }
        for(int k=0;k<10;k++){
            for(int l=k;l<10;l++){
                if(l==x)dp[i+1][1][l] = (dp[i+1][1][l]+dp[i][1][k])%N;
                else{
                    dp[i+1][1][l] = (dp[i+1][1][l]+dp[i][1][k])%N;
                }
            }
        }
    }
    ll ans = 0;
    for(ll i=0;i<10;i++){
        ans = (ans+dp[n][1][i])%N;
        ans = (ans+dp[n][0][i])%N;
    }
    cout<<ans<<endl;
}
0