結果

問題 No.1417 100の倍数かつ正整数(2)
ユーザー zumin
提出日時 2021-03-06 00:07:34
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 176 ms / 3,000 ms
コード長 1,112 bytes
コンパイル時間 3,027 ms
コンパイル使用メモリ 141,400 KB
実行使用メモリ 34,940 KB
最終ジャッジ日時 2024-10-07 06:26:24
合計ジャッジ時間 5,646 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 36
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <atcoder/all>

using namespace std;
using namespace atcoder;

using mint=modint1000000007;
mint dp[10005][100][2][2][2];
int dic2[10],dic5[10];

int main(){
    string s;
    cin>>s;
    int n=s.length();
    dp[0][1][1][0][0]=1;
    

    for(int i=1;i<10;i++){
        int tmp=i;
        while(tmp%2==0){
            dic2[i]++;
            tmp/=2;
        }
        while(tmp%5==0){
            dic5[i]++;
            tmp/=5;
        }
    }

    for(int i=0;i<n;i++){
        int curdig=s[i]-'0';
        for(int smaller=0;smaller<2;smaller++){
            for(int d=0;d<=(smaller?9:curdig);d++){
                for(int j=0;j<100;j++){
                    for(int ldz=0;ldz<2;ldz++){
                        for(int containz=0;containz<2;containz++){
                            dp[i+1][d==0?j:(j*d)%100][ldz==1&&d==0][containz || (d==0 && ldz==0)][smaller || d<curdig]+=dp[i][j][ldz][containz][smaller];
                        }
                    }
                }
            }
        }
    }

    cout<<(dp[n][0][0][0][0]+dp[n][0][0][0][1]).val()<<endl;

    return 0;
}
0