結果

問題 No.741 AscNumber(Easy)
ユーザー weizenweizen
提出日時 2018-10-05 21:51:10
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 143 ms / 2,000 ms
コード長 827 bytes
コンパイル時間 191 ms
コンパイル使用メモリ 23,040 KB
実行使用メモリ 79,640 KB
最終ジャッジ日時 2024-04-20 17:10:28
合計ジャッジ時間 3,424 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 4 ms
20,064 KB
testcase_01 AC 3 ms
20,068 KB
testcase_02 AC 4 ms
20,068 KB
testcase_03 AC 3 ms
20,068 KB
testcase_04 AC 4 ms
19,940 KB
testcase_05 AC 4 ms
20,064 KB
testcase_06 AC 4 ms
20,068 KB
testcase_07 AC 4 ms
19,940 KB
testcase_08 AC 4 ms
19,940 KB
testcase_09 AC 3 ms
20,064 KB
testcase_10 AC 4 ms
19,936 KB
testcase_11 AC 4 ms
19,944 KB
testcase_12 AC 4 ms
20,068 KB
testcase_13 AC 3 ms
20,068 KB
testcase_14 AC 3 ms
20,068 KB
testcase_15 AC 4 ms
20,068 KB
testcase_16 AC 4 ms
20,068 KB
testcase_17 AC 4 ms
19,936 KB
testcase_18 AC 4 ms
19,936 KB
testcase_19 AC 4 ms
19,944 KB
testcase_20 AC 3 ms
19,944 KB
testcase_21 AC 3 ms
19,936 KB
testcase_22 AC 3 ms
19,936 KB
testcase_23 AC 5 ms
20,068 KB
testcase_24 AC 4 ms
20,064 KB
testcase_25 AC 3 ms
20,068 KB
testcase_26 AC 3 ms
20,064 KB
testcase_27 AC 3 ms
20,064 KB
testcase_28 AC 4 ms
19,940 KB
testcase_29 AC 4 ms
20,072 KB
testcase_30 AC 4 ms
20,068 KB
testcase_31 AC 3 ms
20,068 KB
testcase_32 AC 3 ms
20,072 KB
testcase_33 AC 4 ms
20,072 KB
testcase_34 AC 4 ms
20,068 KB
testcase_35 AC 138 ms
79,156 KB
testcase_36 AC 62 ms
52,024 KB
testcase_37 AC 73 ms
59,064 KB
testcase_38 AC 73 ms
57,288 KB
testcase_39 AC 63 ms
53,156 KB
testcase_40 AC 83 ms
63,708 KB
testcase_41 AC 122 ms
78,720 KB
testcase_42 AC 68 ms
56,136 KB
testcase_43 AC 52 ms
46,676 KB
testcase_44 AC 101 ms
74,412 KB
testcase_45 AC 109 ms
78,948 KB
testcase_46 AC 128 ms
78,844 KB
testcase_47 AC 25 ms
31,064 KB
testcase_48 AC 128 ms
79,596 KB
testcase_49 AC 109 ms
78,620 KB
testcase_50 AC 20 ms
28,524 KB
testcase_51 AC 53 ms
45,128 KB
testcase_52 AC 142 ms
79,640 KB
testcase_53 AC 143 ms
79,640 KB
testcase_54 AC 141 ms
79,592 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:9:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
    9 |         scanf("%d",&N);
      |         ~~~~~^~~~~~~~~

ソースコード

diff #

#include <stdio.h>
#include <string.h>

#define MOD 1000000007
typedef long long ll;
ll dp[10][1000001]; // dp[i][j]: j桁の数のうち、先頭がiであるような場合の数
int N;
int main(){
        scanf("%d",&N);
        for(int i = 0; i <= 9; i++) dp[i][1] = 1;
        for(int n = 2; n <= N; n++){
                for(int i = 0; i <= 9; i++){
                        dp[i][n] = 0;
                        for(int j = i; j <= 9; j++){
                                dp[i][n] += dp[j][n-1];
                                dp[i][n] %= MOD;
                        }
                        //printf("dp[i][n]=%lld\n",dp[i][n]);
                }
        }
        ll ans = 0;
        for(int j = 0; j <= 9; j++){
                ans += dp[j][N];
                ans %= MOD;
        }
        printf("%lld\n",ans);
}
0