結果

問題 No.1417 100の倍数かつ正整数(2)
ユーザー ぷらぷら
提出日時 2021-03-05 21:51:54
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 99 ms / 3,000 ms
コード長 3,164 bytes
コンパイル時間 1,678 ms
コンパイル使用メモリ 164,232 KB
実行使用メモリ 44,800 KB
最終ジャッジ日時 2024-04-16 09:18:29
合計ジャッジ時間 3,534 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,812 KB
testcase_01 AC 2 ms
6,940 KB
testcase_02 AC 3 ms
6,944 KB
testcase_03 AC 2 ms
6,940 KB
testcase_04 AC 1 ms
6,944 KB
testcase_05 AC 2 ms
6,940 KB
testcase_06 AC 1 ms
6,944 KB
testcase_07 AC 2 ms
6,944 KB
testcase_08 AC 2 ms
6,944 KB
testcase_09 AC 2 ms
6,940 KB
testcase_10 AC 2 ms
6,940 KB
testcase_11 AC 2 ms
6,944 KB
testcase_12 AC 2 ms
6,944 KB
testcase_13 AC 2 ms
6,940 KB
testcase_14 AC 2 ms
6,944 KB
testcase_15 AC 2 ms
6,940 KB
testcase_16 AC 3 ms
6,940 KB
testcase_17 AC 2 ms
6,944 KB
testcase_18 AC 3 ms
6,944 KB
testcase_19 AC 3 ms
6,940 KB
testcase_20 AC 2 ms
6,940 KB
testcase_21 AC 3 ms
6,940 KB
testcase_22 AC 3 ms
6,944 KB
testcase_23 AC 3 ms
6,944 KB
testcase_24 AC 2 ms
6,944 KB
testcase_25 AC 3 ms
6,940 KB
testcase_26 AC 3 ms
6,940 KB
testcase_27 AC 3 ms
6,944 KB
testcase_28 AC 3 ms
6,940 KB
testcase_29 AC 3 ms
6,940 KB
testcase_30 AC 10 ms
6,944 KB
testcase_31 AC 11 ms
7,680 KB
testcase_32 AC 22 ms
11,776 KB
testcase_33 AC 45 ms
23,936 KB
testcase_34 AC 89 ms
43,648 KB
testcase_35 AC 91 ms
44,544 KB
testcase_36 AC 90 ms
44,544 KB
testcase_37 AC 99 ms
44,672 KB
testcase_38 AC 86 ms
44,800 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using pcc = pair<char,char>;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
using pdd = pair<ld,ld>;
using tuplis = array<ll,3>;
template<class T> using prique = priority_queue<T,vector<T>,greater<T>>;
#define rep(i,n) for(ll i = 0; i < n; i++)
#define rrep(i,n) for(ll i = n-1; i >= 0; i--)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define Sort(a) sort(all(a))
#define Rev(a) reverse(all(a))
#define Uniq(a) sort(all(a));a.erase(unique(all(a)),a.end())
const ll LINF = 1001001001001001001;
const int INF = 1001001001;
const int MOD = 1000000007;
const int MODD = 998244353;
const ld PI = 3.1415926535897932;
const ll dx[] = {0, 1, 0, -1, 1, -1, 1, -1};
const ll dy[] = {1, 0, -1, 0, 1, 1, -1, -1};
inline ll popcnt(ll a){ return __builtin_popcountll(a); }
inline ll intpow(ll a, ll b){ ll ans = 1; while(b){ if(b & 1) ans *= a; a *= a; b /= 2; } return ans; }
inline ll modpow(ll a, ll b, ll p){ ll ans = 1; while(b){ if(b & 1) (ans *= a) %= p; (a *= a) %= p; b /= 2; } return ans; }
ll gcd(ll a,ll b){ if(a%b == 0){return b; } else{ return gcd(b,a%b); } }
ll lcm(ll a,ll b){ return a/gcd(a,b)*b; }
template<class T> bool chmin(T& a, const T& b){ if(a > b){ a = b; return 1; } return 0; }
template<class T> bool chmax(T& a, const T& b){ if(a < b){ a = b; return 1; } return 0; }
template<class T, class U> bool chmin(T& a, const U& b){ if(a > T(b)){ a = b; return 1; } return 0; }
template<class T, class U> bool chmax(T& a, const U& b){ if(a < T(b)){ a = b; return 1; } return 0; }
ll dp[100005][105][5];
int main() {
    string N;
    cin >> N;
    for(int i = 0; i < N.size(); i++) {
        for(int j = 0; j < 100; j++) {
            for(int k = 1; k < 10; k++) {
                if(N[i]-'0' == k) {
                    dp[i+1][(j*k)%100][1] += dp[i][j][1];
                    dp[i+1][(j*k)%100][1] %= MOD;
                    dp[i+1][(j*k)%100][0] += dp[i][j][0];
                    dp[i+1][(j*k)%100][0] %= MOD;
                }
                else if(N[i]-'0' > k) {
                    dp[i+1][(j*k)%100][0] += dp[i][j][1];
                    dp[i+1][(j*k)%100][0] %= MOD;
                    dp[i+1][(j*k)%100][0] += dp[i][j][0];
                    dp[i+1][(j*k)%100][0] %= MOD;
                }
                else {
                    dp[i+1][(j*k)%100][0] += dp[i][j][0];
                    dp[i+1][(j*k)%100][0] %= MOD;
                }
            }
        }
        for(int j = 1; j < 10; j++) {
            if(N[i]-'0' == j) {
                if(i == 0) {
                    dp[i+1][j][1]++;
                    dp[i+1][j][1] %= MOD;
                }
                else {
                    dp[i+1][j][0]++;
                    dp[i+1][j][0] %= MOD;
                }
            }
            else if(N[i]-'0' > j) {
                dp[i+1][j][0]++;
                dp[i+1][j][0] %= MOD;
            }
            else if(i != 0) {
                dp[i+1][j][0]++;
                dp[i+1][j][0] %= MOD;
            }
        }
    }
    cout << (dp[N.size()][0][0]+dp[N.size()][0][1]+MOD)%MOD << endl;
}
0