結果

問題 No.1417 100の倍数かつ正整数(2)
ユーザー HaaHaa
提出日時 2021-03-05 22:00:09
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 8 ms / 3,000 ms
コード長 1,109 bytes
コンパイル時間 1,596 ms
コンパイル使用メモリ 166,324 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-04-16 09:28:40
合計ジャッジ時間 2,719 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 3 ms
6,816 KB
testcase_01 AC 3 ms
6,812 KB
testcase_02 AC 3 ms
6,940 KB
testcase_03 AC 2 ms
6,944 KB
testcase_04 AC 3 ms
6,944 KB
testcase_05 AC 3 ms
6,940 KB
testcase_06 AC 3 ms
6,940 KB
testcase_07 AC 3 ms
6,940 KB
testcase_08 AC 3 ms
6,940 KB
testcase_09 AC 3 ms
6,940 KB
testcase_10 AC 3 ms
6,940 KB
testcase_11 AC 3 ms
6,940 KB
testcase_12 AC 3 ms
6,944 KB
testcase_13 AC 3 ms
6,944 KB
testcase_14 AC 3 ms
6,940 KB
testcase_15 AC 3 ms
6,944 KB
testcase_16 AC 3 ms
6,944 KB
testcase_17 AC 3 ms
6,940 KB
testcase_18 AC 3 ms
6,940 KB
testcase_19 AC 3 ms
6,944 KB
testcase_20 AC 3 ms
6,944 KB
testcase_21 AC 3 ms
6,940 KB
testcase_22 AC 3 ms
6,944 KB
testcase_23 AC 3 ms
6,940 KB
testcase_24 AC 3 ms
6,944 KB
testcase_25 AC 3 ms
6,940 KB
testcase_26 AC 3 ms
6,944 KB
testcase_27 AC 4 ms
6,940 KB
testcase_28 AC 3 ms
6,940 KB
testcase_29 AC 3 ms
6,940 KB
testcase_30 AC 4 ms
6,940 KB
testcase_31 AC 3 ms
6,940 KB
testcase_32 AC 4 ms
6,944 KB
testcase_33 AC 6 ms
6,944 KB
testcase_34 AC 8 ms
6,940 KB
testcase_35 AC 8 ms
6,944 KB
testcase_36 AC 8 ms
6,944 KB
testcase_37 AC 8 ms
6,944 KB
testcase_38 AC 8 ms
6,940 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> P;
typedef vector<ll> VI;
typedef vector<VI> VVI;
#define REP(i,n) for(int i=0;i<(n);i++)
#define ALL(v) v.begin(),v.end()
constexpr ll MOD=1000000007;
constexpr ll INF=2e18;

int main(){
    string s; cin >> s;
    int n=s.size();
    ll dp[10010][2][3][3]={0};
    REP(i,n-1)
        dp[i+1][1][0][0]=1;
    dp[0][0][0][0]=1;
    REP(i,n){
        REP(j,3)REP(k,3)REP(l,10){
            if(l==0) continue;
            int toj=j, tok=k;
            if(l==2||l==6)
                toj=min(2,j+1);
            else if(l==4||l==8)
                toj=min(2,j+2);
            else if(l==5)
                tok=min(2,k+1);
            dp[i+1][1][toj][tok]+=dp[i][1][j][k];
            if(l<s[i]-'0')
                dp[i+1][1][toj][tok]+=dp[i][0][j][k];
            else if(l==s[i]-'0')
                dp[i+1][0][toj][tok]+=dp[i][0][j][k];
            dp[i+1][0][toj][tok]%=MOD;
            dp[i+1][1][toj][tok]%=MOD;
        }
    }
    ll ans=dp[n][1][2][2]+dp[n][0][2][2];
    cout << ans%MOD << endl;
    return 0;
}
0