結果

問題 No.741 AscNumber(Easy)
ユーザー onakaT_TitaionakaT_Titai
提出日時 2018-10-05 23:16:11
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 118 ms / 2,000 ms
コード長 1,508 bytes
コンパイル時間 642 ms
コンパイル使用メモリ 85,080 KB
実行使用メモリ 81,540 KB
最終ジャッジ日時 2023-08-02 17:21:35
合計ジャッジ時間 3,975 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 2 ms
4,376 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 2 ms
4,380 KB
testcase_07 AC 2 ms
4,376 KB
testcase_08 AC 1 ms
4,380 KB
testcase_09 AC 2 ms
4,380 KB
testcase_10 AC 1 ms
4,376 KB
testcase_11 AC 1 ms
4,376 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,380 KB
testcase_16 AC 1 ms
4,376 KB
testcase_17 AC 2 ms
4,376 KB
testcase_18 AC 2 ms
4,376 KB
testcase_19 AC 2 ms
4,376 KB
testcase_20 AC 1 ms
4,380 KB
testcase_21 AC 2 ms
4,376 KB
testcase_22 AC 2 ms
4,376 KB
testcase_23 AC 2 ms
4,376 KB
testcase_24 AC 2 ms
4,376 KB
testcase_25 AC 1 ms
4,376 KB
testcase_26 AC 2 ms
4,376 KB
testcase_27 AC 2 ms
4,380 KB
testcase_28 AC 1 ms
4,376 KB
testcase_29 AC 1 ms
4,380 KB
testcase_30 AC 2 ms
4,376 KB
testcase_31 AC 2 ms
4,380 KB
testcase_32 AC 2 ms
4,376 KB
testcase_33 AC 2 ms
4,376 KB
testcase_34 AC 2 ms
4,376 KB
testcase_35 AC 112 ms
77,964 KB
testcase_36 AC 50 ms
35,792 KB
testcase_37 AC 58 ms
41,552 KB
testcase_38 AC 57 ms
41,000 KB
testcase_39 AC 48 ms
35,196 KB
testcase_40 AC 65 ms
46,644 KB
testcase_41 AC 103 ms
71,404 KB
testcase_42 AC 56 ms
39,392 KB
testcase_43 AC 40 ms
29,332 KB
testcase_44 AC 80 ms
56,604 KB
testcase_45 AC 86 ms
60,720 KB
testcase_46 AC 107 ms
74,232 KB
testcase_47 AC 20 ms
15,320 KB
testcase_48 AC 107 ms
74,188 KB
testcase_49 AC 88 ms
62,596 KB
testcase_50 AC 14 ms
11,464 KB
testcase_51 AC 42 ms
30,676 KB
testcase_52 AC 118 ms
81,528 KB
testcase_53 AC 117 ms
81,540 KB
testcase_54 AC 116 ms
80,692 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <bitset>
#include <fstream>
#include <string>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <vector>
#include <algorithm>
#include <numeric>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <functional>
#include <cctype>
#include <list>
#include <limits>
//#include <boost/multiprecision/cpp_int.hpp>

const double EPS = (1e-10);


using namespace std;
using Int = long long;
//using namespace boost::multiprecision;

const Int MOD = 1000000007;

Int mod_pow(Int x, Int n) {
    Int res = 1;
    while(n > 0) {
        if(n & 1) res = (res * x) % MOD; //ビット演算(最下位ビットが1のとき)
        x = (x * x) % MOD;
        n >>= 1; //右シフト(n = n >> 1)
    }
    return res;
}

Int dp[1000000][10];

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

    dp[1][9] = 1;
    for (int i = 8; i >= 0; i--){
        dp[1][i] = dp[1][i+1] + 1;
    }
    if (N == 1){
        cout << 10 << endl;
        return 0;
    }
    for (int i = 2; i <= N-1; i++){
        for (int j = 9; j >= 0; j--){
            dp[i][j] += dp[i-1][j];
            dp[i][j] %= MOD; 
        }
        for (int j = 8; j >= 0; j--){
            dp[i][j] += dp[i][j+1];
        }
    }
    Int ans = 0;
    for (int i = 9; i > 0; i--){
        ans += dp[N-1][i];
        ans %= MOD;
    }
    for (int i = 1; i <= N-1; i++){
        ans += dp[i][1];
        ans %= MOD;
    }
    ans++;
    ans %= MOD;
    cout << ans << endl;

} 
0