結果

問題 No.741 AscNumber(Easy)
ユーザー umezoumezo
提出日時 2021-07-13 03:16:25
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 566 ms / 2,000 ms
コード長 695 bytes
コンパイル時間 1,955 ms
コンパイル使用メモリ 201,020 KB
実行使用メモリ 160,672 KB
最終ジャッジ日時 2023-09-14 23:53:11
合計ジャッジ時間 11,617 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 2 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 1 ms
4,380 KB
testcase_07 AC 2 ms
4,380 KB
testcase_08 AC 1 ms
4,376 KB
testcase_09 AC 2 ms
4,376 KB
testcase_10 AC 2 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,380 KB
testcase_15 AC 2 ms
4,376 KB
testcase_16 AC 1 ms
4,380 KB
testcase_17 AC 1 ms
4,376 KB
testcase_18 AC 2 ms
4,376 KB
testcase_19 AC 2 ms
4,376 KB
testcase_20 AC 2 ms
4,380 KB
testcase_21 AC 2 ms
4,376 KB
testcase_22 AC 2 ms
4,380 KB
testcase_23 AC 2 ms
4,376 KB
testcase_24 AC 2 ms
4,380 KB
testcase_25 AC 2 ms
4,376 KB
testcase_26 AC 2 ms
4,376 KB
testcase_27 AC 2 ms
4,380 KB
testcase_28 AC 2 ms
4,376 KB
testcase_29 AC 2 ms
4,380 KB
testcase_30 AC 2 ms
4,376 KB
testcase_31 AC 2 ms
4,376 KB
testcase_32 AC 2 ms
4,380 KB
testcase_33 AC 2 ms
4,376 KB
testcase_34 AC 2 ms
4,376 KB
testcase_35 AC 541 ms
153,012 KB
testcase_36 AC 234 ms
68,500 KB
testcase_37 AC 275 ms
80,104 KB
testcase_38 AC 277 ms
79,040 KB
testcase_39 AC 232 ms
67,144 KB
testcase_40 AC 314 ms
90,304 KB
testcase_41 AC 484 ms
139,828 KB
testcase_42 AC 262 ms
75,564 KB
testcase_43 AC 187 ms
55,548 KB
testcase_44 AC 382 ms
110,380 KB
testcase_45 AC 413 ms
118,780 KB
testcase_46 AC 517 ms
145,616 KB
testcase_47 AC 90 ms
27,504 KB
testcase_48 AC 511 ms
145,676 KB
testcase_49 AC 421 ms
122,184 KB
testcase_50 AC 61 ms
19,640 KB
testcase_51 AC 197 ms
58,384 KB
testcase_52 AC 559 ms
160,672 KB
testcase_53 AC 566 ms
160,548 KB
testcase_54 AC 555 ms
158,752 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define ALL(v) v.begin(),v.end()
typedef long long ll;
 
#include<bits/stdc++.h>
using namespace std;

ll dp[1000100][2][10];
const int MOD=1e9+7;

int main() {
  ios::sync_with_stdio(false);
  std::cin.tie(nullptr);
  
  int n;
  cin>>n;
  string N="1";
  rep(i,n) N+='0';
  
  dp[0][0][0]=1;
  rep(i,n+1){
    int Ni=N[i]-'0';
    rep(j,2) rep(k,10) rep(x,10){
      int j2=j,k2=k;
      
      if(x<k2) continue;
      k2=x;
        
      if(!j2 && (x>Ni)) continue;
      if(x<Ni) j2=1;

      dp[i+1][j2][k2]=(dp[i+1][j2][k2]+dp[i][j][k])%MOD;
    }
  }
  ll ans=0;
  rep(i,10) ans=(ans+dp[n+1][1][i])%MOD;
  cout<<ans<<endl;
    
  return 0;
}
0