結果

問題 No.189 SUPER HAPPY DAY
ユーザー Ai3Shota
提出日時 2018-02-08 09:50:59
言語 C
(gcc 13.3.0)
結果
WA  
実行時間 -
コード長 1,136 bytes
コンパイル時間 225 ms
コンパイル使用メモリ 30,208 KB
実行使用メモリ 8,608 KB
最終ジャッジ日時 2024-09-22 04:00:02
合計ジャッジ時間 7,028 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2 WA * 1
other AC * 10 TLE * 1 -- * 12
権限があれば一括ダウンロードができます

ソースコード

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