結果

問題 No.741 AscNumber(Easy)
ユーザー satou_a_mansatou_a_man
提出日時 2018-11-04 16:00:21
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 231 ms / 2,000 ms
コード長 697 bytes
コンパイル時間 1,057 ms
コンパイル使用メモリ 158,724 KB
実行使用メモリ 120,560 KB
最終ジャッジ日時 2024-04-30 21:47:24
合計ジャッジ時間 5,580 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 11 ms
42,516 KB
testcase_01 AC 10 ms
42,372 KB
testcase_02 AC 11 ms
42,420 KB
testcase_03 AC 11 ms
42,432 KB
testcase_04 AC 11 ms
42,444 KB
testcase_05 AC 11 ms
42,468 KB
testcase_06 AC 9 ms
42,284 KB
testcase_07 AC 11 ms
42,356 KB
testcase_08 AC 10 ms
42,404 KB
testcase_09 AC 11 ms
42,488 KB
testcase_10 AC 10 ms
42,420 KB
testcase_11 AC 11 ms
42,392 KB
testcase_12 AC 10 ms
42,364 KB
testcase_13 AC 10 ms
42,436 KB
testcase_14 AC 11 ms
42,412 KB
testcase_15 AC 10 ms
42,420 KB
testcase_16 AC 10 ms
42,468 KB
testcase_17 AC 11 ms
42,460 KB
testcase_18 AC 11 ms
42,392 KB
testcase_19 AC 11 ms
42,276 KB
testcase_20 AC 11 ms
42,388 KB
testcase_21 AC 11 ms
42,384 KB
testcase_22 AC 11 ms
42,460 KB
testcase_23 AC 11 ms
42,428 KB
testcase_24 AC 11 ms
42,436 KB
testcase_25 AC 10 ms
42,268 KB
testcase_26 AC 11 ms
42,516 KB
testcase_27 AC 11 ms
42,428 KB
testcase_28 AC 10 ms
42,480 KB
testcase_29 AC 11 ms
42,424 KB
testcase_30 AC 11 ms
42,436 KB
testcase_31 AC 11 ms
42,376 KB
testcase_32 AC 11 ms
42,380 KB
testcase_33 AC 10 ms
42,464 KB
testcase_34 AC 11 ms
42,468 KB
testcase_35 AC 216 ms
116,880 KB
testcase_36 AC 100 ms
74,884 KB
testcase_37 AC 119 ms
80,580 KB
testcase_38 AC 116 ms
80,004 KB
testcase_39 AC 99 ms
74,120 KB
testcase_40 AC 131 ms
85,660 KB
testcase_41 AC 200 ms
110,332 KB
testcase_42 AC 112 ms
78,540 KB
testcase_43 AC 85 ms
68,396 KB
testcase_44 AC 171 ms
95,460 KB
testcase_45 AC 187 ms
99,756 KB
testcase_46 AC 208 ms
113,268 KB
testcase_47 AC 46 ms
54,428 KB
testcase_48 AC 212 ms
113,276 KB
testcase_49 AC 182 ms
101,604 KB
testcase_50 AC 34 ms
50,436 KB
testcase_51 AC 88 ms
69,764 KB
testcase_52 AC 225 ms
120,560 KB
testcase_53 AC 227 ms
120,496 KB
testcase_54 AC 231 ms
119,704 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#include <unordered_set>
using namespace std;
#define ll long long
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define repeat(i,s,n) for(int (i)=s; (i)<(n); (i)++)
#define revrep(i,n) for(int (i)=(n)-1;i>=0; i--)

const ll p = 1e9+7;
int memo[10][1000000+1];

int rec(int prev, int n) {
  if(memo[prev][n]>=0) return memo[prev][n];
  if(n==0) return 1;
  ll ans=0;
  repeat(i,prev,10) {
    ans+=rec(i,n-1);
    ans%=p;
  }
  return memo[prev][n]=ans;
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout<<setprecision(std::numeric_limits<float>::max_digits10);
  int n;
  cin>>n;
  memset(memo,-1,sizeof(memo));
  cout << rec(0,n) << endl;
  return 0;
}
0