結果

問題 No.1417 100の倍数かつ正整数(2)
ユーザー eQeeQe
提出日時 2021-03-09 19:48:52
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 18 ms / 3,000 ms
コード長 1,557 bytes
コンパイル時間 3,935 ms
コンパイル使用メモリ 231,876 KB
実行使用メモリ 10,412 KB
最終ジャッジ日時 2024-04-19 20:19:41
合計ジャッジ時間 5,240 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 11 ms
10,256 KB
testcase_01 AC 11 ms
10,124 KB
testcase_02 AC 11 ms
10,256 KB
testcase_03 AC 11 ms
10,256 KB
testcase_04 AC 12 ms
10,132 KB
testcase_05 AC 10 ms
10,384 KB
testcase_06 AC 11 ms
10,260 KB
testcase_07 AC 11 ms
10,384 KB
testcase_08 AC 11 ms
10,124 KB
testcase_09 AC 11 ms
10,260 KB
testcase_10 AC 11 ms
10,132 KB
testcase_11 AC 10 ms
10,256 KB
testcase_12 AC 11 ms
10,388 KB
testcase_13 AC 11 ms
10,256 KB
testcase_14 AC 12 ms
10,380 KB
testcase_15 AC 11 ms
10,256 KB
testcase_16 AC 12 ms
10,128 KB
testcase_17 AC 12 ms
10,384 KB
testcase_18 AC 12 ms
10,384 KB
testcase_19 AC 11 ms
10,256 KB
testcase_20 AC 11 ms
10,256 KB
testcase_21 AC 11 ms
10,128 KB
testcase_22 AC 11 ms
10,256 KB
testcase_23 AC 11 ms
10,256 KB
testcase_24 AC 11 ms
10,128 KB
testcase_25 AC 11 ms
10,256 KB
testcase_26 AC 11 ms
10,384 KB
testcase_27 AC 11 ms
10,252 KB
testcase_28 AC 11 ms
10,256 KB
testcase_29 AC 12 ms
10,252 KB
testcase_30 AC 12 ms
10,256 KB
testcase_31 AC 11 ms
10,264 KB
testcase_32 AC 12 ms
10,136 KB
testcase_33 AC 13 ms
10,268 KB
testcase_34 AC 16 ms
10,280 KB
testcase_35 AC 16 ms
10,152 KB
testcase_36 AC 16 ms
10,280 KB
testcase_37 AC 18 ms
10,408 KB
testcase_38 AC 15 ms
10,412 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#define pt(sth) cout << sth << "\n"
#define itr(x,c) for(auto x=c.begin();x!=c.end();x++)
#define all(a) (a.begin()),(a.end())
using namespace std;
#include <atcoder/all>
using namespace atcoder;
typedef long long ll;
typedef pair<ll, ll> pll;
template<class T>bool chmax(T &a, const T &b) {if(a<b) {a=b; return 1;} return 0;}
template<class T>bool chmin(T &a, const T &b) {if(b<a) {a=b; return 1;} return 0;}
static const ll INF=1e18;
static const ll MAX=101010;
static const ll MOD=1e9+7;
//static const ll MOD=998244353;
//for(i=0;i<N;i++) cin>>a[i];

typedef vector<ll> v1D;
typedef vector<v1D> v2D;
typedef vector<v2D> v3D;
typedef vector<v3D> v4D;

v4D dp(11111,v3D(3,v2D(3,v1D(2,0))));

int main(void) {
  ll i,j,k,l;
  
  string s;cin>>s;
  // dp[i+1][2][5][eq]
  dp[0][0][0][1]=1;
  for(i=0;i<s.size();i++) dp[i+1][0][0][0]=1;
  for(i=0;i<s.size();i++){
    for(j=0;j<3;j++){
      for(k=0;k<3;k++){
        for(l=0;l<2;l++){
          ll lim=(l==1?s[i]-'0':9);
          
          for(ll d=1;d<=lim;d++){
            if(d%4==0){
              (dp[i+1][min(j+2,2LL)][k][l and d==lim]+=dp[i][j][k][l])%=MOD;
            }else if(d%2==0){
              (dp[i+1][min(j+1,2LL)][k][l and d==lim]+=dp[i][j][k][l])%=MOD;
            }else if(d%5==0){
              (dp[i+1][j][min(k+1,2LL)][l and d==lim]+=dp[i][j][k][l])%=MOD;
            }else{
              (dp[i+1][j][k][l and d==lim]+=dp[i][j][k][l])%=MOD;
            }
          }
        }
      }
    }
  }
  
  pt((dp[s.size()][2][2][0]+dp[s.size()][2][2][1])%MOD);
}
0