結果

問題 No.2032 Let's Write Multiples!!
ユーザー ShirotsumeShirotsume
提出日時 2022-07-14 02:55:44
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 407 ms / 3,000 ms
コード長 716 bytes
コンパイル時間 4,109 ms
コンパイル使用メモリ 259,824 KB
実行使用メモリ 4,504 KB
最終ジャッジ日時 2023-09-07 14:41:05
合計ジャッジ時間 13,341 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 177 ms
4,380 KB
testcase_02 AC 147 ms
4,380 KB
testcase_03 AC 132 ms
4,380 KB
testcase_04 AC 224 ms
4,384 KB
testcase_05 AC 406 ms
4,376 KB
testcase_06 AC 355 ms
4,380 KB
testcase_07 AC 186 ms
4,376 KB
testcase_08 AC 268 ms
4,380 KB
testcase_09 AC 390 ms
4,380 KB
testcase_10 AC 282 ms
4,376 KB
testcase_11 AC 276 ms
4,380 KB
testcase_12 AC 261 ms
4,380 KB
testcase_13 AC 269 ms
4,376 KB
testcase_14 AC 244 ms
4,380 KB
testcase_15 AC 225 ms
4,376 KB
testcase_16 AC 223 ms
4,380 KB
testcase_17 AC 225 ms
4,380 KB
testcase_18 AC 407 ms
4,380 KB
testcase_19 AC 220 ms
4,376 KB
testcase_20 AC 156 ms
4,380 KB
testcase_21 AC 173 ms
4,376 KB
testcase_22 AC 172 ms
4,380 KB
testcase_23 AC 173 ms
4,384 KB
testcase_24 AC 189 ms
4,504 KB
権限があれば一括ダウンロードができます

ソースコード

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 solve(){
    ll l, r, k, c;
    cin >> 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