結果

問題 No.2032 Let's Write Multiples!!
ユーザー 遭難者遭難者
提出日時 2023-06-07 00:25:08
言語 C++23
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 529 ms / 3,000 ms
コード長 765 bytes
コンパイル時間 5,672 ms
コンパイル使用メモリ 306,580 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-08-28 10:53:34
合計ジャッジ時間 13,160 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 133 ms
4,376 KB
testcase_02 AC 90 ms
4,376 KB
testcase_03 AC 68 ms
4,376 KB
testcase_04 AC 194 ms
4,380 KB
testcase_05 AC 527 ms
4,376 KB
testcase_06 AC 441 ms
4,376 KB
testcase_07 AC 157 ms
4,376 KB
testcase_08 AC 299 ms
4,376 KB
testcase_09 AC 507 ms
4,380 KB
testcase_10 AC 314 ms
4,376 KB
testcase_11 AC 313 ms
4,376 KB
testcase_12 AC 290 ms
4,376 KB
testcase_13 AC 291 ms
4,380 KB
testcase_14 AC 254 ms
4,380 KB
testcase_15 AC 192 ms
4,380 KB
testcase_16 AC 192 ms
4,376 KB
testcase_17 AC 194 ms
4,380 KB
testcase_18 AC 529 ms
4,380 KB
testcase_19 AC 196 ms
4,376 KB
testcase_20 AC 98 ms
4,380 KB
testcase_21 AC 124 ms
4,376 KB
testcase_22 AC 123 ms
4,376 KB
testcase_23 AC 123 ms
4,376 KB
testcase_24 AC 124 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#include <atcoder/all>
#define rep(i, n) for (int i = 0; i < n; i++)
#define ALL(a) a.begin(), a.end()
#define ll long long
using namespace std;
using namespace atcoder;
ll ten[11];
ll f(ll r, ll k, ll c)
{
	ll ans = 0;
	rep(i, 9)
	{
		ans += floor_sum(r, ten[i + 1], k, ten[i + 1] - c * ten[i] + k);
		ans -= floor_sum(r, ten[i + 1], k, k);
	}
	return ans;
}
void solve()
{
	ll l, r, k, c;
	cin >> l >> r >> k >> c;
	l = (l - 1) / k;
	r = r / k;
	ll ans = f(r, k, c) - f(r, k, c + 1) - f(l, k, c) + f(l, k, c + 1);
	cout << ans << '\n';
}
int main()
{
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(13);
	ten[0] = 1;
	rep(i, 10) ten[i + 1] = 10 * ten[i];
	int t;
	cin >> t;
	rep(i, t) solve();
	return 0;
}
0