結果

問題 No.2032 Let's Write Multiples!!
ユーザー ShirotsumeShirotsume
提出日時 2022-07-15 02:21:50
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 1,040 bytes
コンパイル時間 4,576 ms
コンパイル使用メモリ 259,924 KB
実行使用メモリ 8,760 KB
最終ジャッジ日時 2023-09-09 18:42:59
合計ジャッジ時間 15,317 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
7,840 KB
testcase_01 AC 150 ms
4,376 KB
testcase_02 AC 146 ms
4,376 KB
testcase_03 AC 129 ms
4,380 KB
testcase_04 AC 134 ms
4,380 KB
testcase_05 AC 2,231 ms
4,376 KB
testcase_06 AC 355 ms
4,376 KB
testcase_07 AC 123 ms
4,376 KB
testcase_08 AC 269 ms
4,380 KB
testcase_09 AC 388 ms
4,376 KB
testcase_10 TLE -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using namespace atcoder;
using mint = modint998244353;
using ll = long long;
#define all(x) x.begin(), x.end()
#define rep(i, n) for (int i = 0; i < n; i++)
ll f(ll r, ll k, ll c){
    ll n = r / k;
    ll ans = 0;
    ll d = 1;
    for(int i = 0; i < 9; i++){
        ll x = c * d;
        ll y = (c + 1) * d;
        d *= 10;
        ans += floor_sum(n, d, k,  d + k - x) - floor_sum(n, d, k,  d + k - y);
    }
    return ans;
}
ll gu(ll l, ll r, ll k, ll c){
    ll s = (l + k - 1) / k;
    ll t = r / k;
    ll ans = 0;
    for(ll i = s; i <= t; i++){
        ll now = k * i;
        while(now > 0){
            if (now % 10 == c) ans++;
            now /= 10;
        }
    }
    return ans;
}
ll solve(){
    ll l, r, k, c;
    cin >> l >> r >> k >> c;
    if(k > 31622){
        return gu(l, r, k, c);
    }
    return f(r, k, c) - f(l - 1, k, c);
}
int main(void)
{
    int t;
    cin >> t;
    rep(i, t){
        cout << solve() << endl;
    }
    return 0;
}

0