結果
問題 | No.189 SUPER HAPPY DAY |
ユーザー | 184 |
提出日時 | 2015-04-22 00:50:11 |
言語 | C++11 (gcc 11.4.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,484 bytes |
コンパイル時間 | 671 ms |
コンパイル使用メモリ | 61,116 KB |
実行使用メモリ | 4,568 KB |
最終ジャッジ日時 | 2023-09-18 06:45:57 |
合計ジャッジ時間 | 1,949 ms |
ジャッジサーバーID (参考情報) |
judge11 / judge15 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 2 ms
4,376 KB |
testcase_01 | WA | - |
testcase_02 | AC | 1 ms
4,380 KB |
testcase_03 | WA | - |
testcase_04 | WA | - |
testcase_05 | WA | - |
testcase_06 | WA | - |
testcase_07 | WA | - |
testcase_08 | WA | - |
testcase_09 | WA | - |
testcase_10 | WA | - |
testcase_11 | WA | - |
testcase_12 | WA | - |
testcase_13 | WA | - |
testcase_14 | WA | - |
testcase_15 | WA | - |
testcase_16 | WA | - |
testcase_17 | WA | - |
testcase_18 | WA | - |
testcase_19 | WA | - |
testcase_20 | WA | - |
testcase_21 | WA | - |
testcase_22 | WA | - |
testcase_23 | WA | - |
testcase_24 | WA | - |
testcase_25 | WA | - |
ソースコード
#include <cstdio> #include <cstdlib> #include <cstring> #include <algorithm> #include <map> #include <vector> using namespace std; int main(){ const long long mod = 1000000009; char m[201],d[201];scanf("%s%s",m,d); long long ans=0; int lm=strlen(m),ld=strlen(d); long long dpm[2001]={},dpd[2001]={}; dpm[0]=dpd[0]=1; if(lm==1&&ld==1){ printf("%d\n",min(m[0]-'0',d[0]-'0')); return 0;; } for(int i=1;i<lm;i++){ for(int j=2000;j>=0;j--){ if(dpm[j]){ for(int k=0;k<10;k++){ dpm[j+k]+=dpm[j]; //if(dpm[j+k]>=mod)dpm[j+k]%=mod; } } } } long long dpmm[2001]={};dpmm[0]=1; for(int i=0;i<lm;i++){ for(int j=2000;j>=0;j--){ if(dpmm[j]){ int k=0,len=m[j]-'0'; if(i==0)k++; for(;k<=len;k++){ dpmm[j+k]+=dpmm[j]; //if(dpmm[j+k]>=mod)dpmm[j+k]%=mod; } } } } for(int i=0;i<2000;i++)dpm[i]+=dpmm[i]; for(int i=1;i<lm;i++){ for(int j=2000;j>=0;j--){ if(dpd[j]){ for(int k=0;k<10;k++){ dpd[j+k]+=dpd[j]; //if(dpd[j+k]>=mod)dpd[j+k]%=mod; } } } } long long dpdd[2001]={};dpdd[0]=1; for(int i=0;i<lm;i++){ for(int j=2000;j>=0;j--){ if(dpdd[j]){ int k=0,len=m[j]-'0'; if(i==0)k++; for(;k<=len;k++){ dpdd[j+k]+=dpdd[j]; //if(dpmm[i+k]>=mod)dpmm[i+k]%=mod; } } } } for(int i=0;i<2000;i++)dpd[i]+=dpdd[i]; for(int i=1;i<2000;i++){ ans+=min(dpm[i],dpd[i]); if(ans>=mod)ans%=mod; } printf("%d\n",(int)ans); return 0; }