結果

問題 No.741 AscNumber(Easy)
ユーザー MiccMicc
提出日時 2019-07-30 22:18:19
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 654 ms / 2,000 ms
コード長 818 bytes
コンパイル時間 1,887 ms
コンパイル使用メモリ 166,016 KB
実行使用メモリ 160,584 KB
最終ジャッジ日時 2023-09-18 15:42:49
合計ジャッジ時間 11,737 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 AC 1 ms
4,380 KB
testcase_05 AC 2 ms
4,376 KB
testcase_06 AC 2 ms
4,376 KB
testcase_07 AC 2 ms
4,376 KB
testcase_08 AC 1 ms
4,376 KB
testcase_09 AC 2 ms
4,376 KB
testcase_10 AC 2 ms
4,376 KB
testcase_11 AC 1 ms
4,380 KB
testcase_12 AC 2 ms
4,376 KB
testcase_13 AC 1 ms
4,380 KB
testcase_14 AC 2 ms
4,376 KB
testcase_15 AC 2 ms
4,376 KB
testcase_16 AC 2 ms
4,380 KB
testcase_17 AC 1 ms
4,380 KB
testcase_18 AC 2 ms
4,380 KB
testcase_19 AC 2 ms
4,376 KB
testcase_20 AC 2 ms
4,380 KB
testcase_21 AC 2 ms
4,380 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 2 ms
4,376 KB
testcase_26 AC 2 ms
4,380 KB
testcase_27 AC 2 ms
4,376 KB
testcase_28 AC 1 ms
4,376 KB
testcase_29 AC 2 ms
4,380 KB
testcase_30 AC 2 ms
4,380 KB
testcase_31 AC 2 ms
4,380 KB
testcase_32 AC 2 ms
4,380 KB
testcase_33 AC 2 ms
4,376 KB
testcase_34 AC 3 ms
4,376 KB
testcase_35 AC 622 ms
153,076 KB
testcase_36 AC 276 ms
68,392 KB
testcase_37 AC 327 ms
80,004 KB
testcase_38 AC 320 ms
78,976 KB
testcase_39 AC 271 ms
67,224 KB
testcase_40 AC 366 ms
90,256 KB
testcase_41 AC 569 ms
139,888 KB
testcase_42 AC 306 ms
75,548 KB
testcase_43 AC 220 ms
55,544 KB
testcase_44 AC 449 ms
110,300 KB
testcase_45 AC 488 ms
118,740 KB
testcase_46 AC 594 ms
145,584 KB
testcase_47 AC 103 ms
27,412 KB
testcase_48 AC 595 ms
145,596 KB
testcase_49 AC 499 ms
122,096 KB
testcase_50 AC 69 ms
19,484 KB
testcase_51 AC 231 ms
58,136 KB
testcase_52 AC 654 ms
160,576 KB
testcase_53 AC 652 ms
160,584 KB
testcase_54 AC 650 ms
158,760 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, a, b) for (ll i = a; i < b; i++)
#define len(v) ll(v.size())
#define fi first
#define se second

template <class T>
void cout_vec(const vector<T> &vec){
  for(auto itr:vec) cout<<itr<<' ';
  cout<<'\n';
}

typedef pair<ll,ll> P;
const ll mod=1e9+7;

ll dp[1000010][2][10];

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin>>n;
    string s;
    rep(i,n) s.push_back('9');
    dp[0][0][0]=1;
    rep(i,n)rep(j,2)rep(k,10){
      int x=s[i]-'0';
      for(int l=k;l<=(j?9:x);l++){
        (dp[i+1][j||(l<x)][l]+=dp[i][j][k])%=mod;
      }
    }
    ll ans=0;
    rep(k,10) (ans+=(dp[n][0][k]+dp[n][1][k])%mod)%=mod;
    cout<<ans<<endl;
}
0