結果

問題 No.260 世界のなんとか3
ユーザー latte0119latte0119
提出日時 2015-12-09 21:38:18
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 105 ms / 2,000 ms
コード長 1,236 bytes
コンパイル時間 1,360 ms
コンパイル使用メモリ 159,216 KB
実行使用メモリ 12,160 KB
最終ジャッジ日時 2024-04-25 07:50:09
合計ジャッジ時間 3,844 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 8 ms
11,008 KB
testcase_01 AC 8 ms
11,008 KB
testcase_02 AC 8 ms
11,008 KB
testcase_03 AC 105 ms
12,032 KB
testcase_04 AC 104 ms
12,032 KB
testcase_05 AC 27 ms
11,392 KB
testcase_06 AC 20 ms
11,264 KB
testcase_07 AC 73 ms
11,776 KB
testcase_08 AC 53 ms
11,904 KB
testcase_09 AC 33 ms
11,520 KB
testcase_10 AC 80 ms
11,904 KB
testcase_11 AC 76 ms
12,032 KB
testcase_12 AC 49 ms
11,776 KB
testcase_13 AC 19 ms
11,008 KB
testcase_14 AC 70 ms
11,904 KB
testcase_15 AC 25 ms
11,264 KB
testcase_16 AC 62 ms
11,520 KB
testcase_17 AC 51 ms
11,520 KB
testcase_18 AC 48 ms
11,520 KB
testcase_19 AC 63 ms
11,904 KB
testcase_20 AC 45 ms
11,520 KB
testcase_21 AC 42 ms
11,520 KB
testcase_22 AC 70 ms
11,776 KB
testcase_23 AC 14 ms
11,136 KB
testcase_24 AC 56 ms
11,904 KB
testcase_25 AC 56 ms
12,160 KB
testcase_26 AC 54 ms
12,032 KB
testcase_27 AC 8 ms
10,880 KB
testcase_28 AC 102 ms
12,160 KB
testcase_29 AC 103 ms
12,032 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;

#define int long long

typedef pair<int,int>pint;
typedef vector<int>vint;
#define pb push_back
#define mp make_pair
#define all(v) (v).begin(),(v).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,f,n) for(int i=(f);i<(n);i++)
template<class T,class U>void chmin(T &t,U f){if(t>f)t=f;}
template<class T,class U>void chmax(T &t,U f){if(t<f)t=f;}

const int mod=1000000007;

string S;
int memo[10101][2][3][2][8];

int dfs(int n,int f,int mod3,int ap3,int mod8){
    if(n==S.size())return (!mod3||ap3)&&mod8;
    if(~memo[n][f][mod3][ap3][mod8])
        return memo[n][f][mod3][ap3][mod8];

    int ret=0;

    rep(i,10){
        if(!f&&S[n]-'0'<i)break;
        ret=(ret+dfs(n+1,f|(S[n]-'0'!=i),(mod3*10+i)%3,ap3|(i==3),(mod8*10+i)%8))%mod;
    }

    return memo[n][f][mod3][ap3][mod8]=ret;
}

signed main(){
    string A,B;cin>>A>>B;
    int ans=0;

    S=B;
    memset(memo,-1,sizeof(memo));
    ans=dfs(0,0,0,0,0);
    S=A;S[S.size()-1]--;
    for(int i=S.size()-1;i>=0;i--){
        int d=S[i]-'0';
        if(d>=0)break;
        S[i]+=10;
        S[i-1]--;
    }
    memset(memo,-1,sizeof(memo));
    ans=(ans-dfs(0,0,0,0,0)+mod)%mod;

    cout<<ans<<endl;
    return 0;
}
0