結果
問題 | No.2032 Let's Write Multiples!! |
ユーザー | Shirotsume |
提出日時 | 2022-07-15 02:21:50 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
TLE
|
実行時間 | - |
コード長 | 1,040 bytes |
コンパイル時間 | 4,500 ms |
コンパイル使用メモリ | 250,228 KB |
最終ジャッジ日時 | 2025-01-30 07:12:01 |
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 20 TLE * 4 |
ソースコード
#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;}