結果

問題 No.189 SUPER HAPPY DAY
ユーザー Ai3ShotaAi3Shota
提出日時 2018-02-08 09:50:59
言語 C
(gcc 12.3.0)
結果
WA  
実行時間 -
コード長 1,136 bytes
コンパイル時間 671 ms
コンパイル使用メモリ 29,992 KB
実行使用メモリ 6,124 KB
最終ジャッジ日時 2023-10-22 02:21:54
合計ジャッジ時間 8,004 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,348 KB
testcase_01 WA -
testcase_02 AC 1 ms
4,348 KB
testcase_03 AC 5 ms
4,348 KB
testcase_04 AC 3 ms
4,348 KB
testcase_05 AC 5 ms
4,348 KB
testcase_06 AC 3 ms
4,348 KB
testcase_07 AC 8 ms
4,348 KB
testcase_08 AC 4 ms
4,348 KB
testcase_09 AC 7 ms
4,348 KB
testcase_10 AC 6 ms
4,348 KB
testcase_11 AC 4 ms
4,348 KB
testcase_12 AC 6 ms
4,348 KB
testcase_13 TLE -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <stdio.h>
#include <string.h>
#include <stdbool.h>
#define MAX_SUM 1800 
#define MAX_DIGIT 205

int mod = 1000000009;
int len = 0;
int s_max = 0;
int M_count[MAX_SUM] = {0};
int D_count[MAX_SUM] = {0};


void DpFunk(const char* str, int* count, int digit, bool tight, int sum){
    
    if(digit == len){
        if(sum > 0) ++count[sum - 1];
        if(sum > s_max) s_max = sum;
        return;
    }

    int x = str[digit] - '0';
    int r = (tight ? x : 9);

    for(int i = 0; i <= r; ++i){
        DpFunk(str, count, digit + 1, tight && i == r, sum + i);
    }

    return;
}



int main(void){
    
    char M_str[MAX_DIGIT] = {0};
    char D_str[MAX_DIGIT] = {0};
    
    scanf("%s", M_str);
    scanf("%s", D_str);

    len = strlen(M_str);
    DpFunk(M_str, M_count, 0, true, 0);

    int roop = s_max;
    
    len = strlen(D_str);
    DpFunk(D_str, D_count, 0, true, 0);
    
    if(roop > s_max) roop = s_max;
    
    int i;
    long long int count = 0;
    for(i = 0; i < roop; ++i){
        count += (M_count[i] * D_count[i]);
        count %= mod;
    }
    
    printf("%lld\n", count);
    
    return 0;
}
0