Submission #70348190
Source Code Expand
#include <bits/stdc++.h>
using namespace std;
#define rep(i, start, end) for (auto i = (start); (i) < (end); (i)++)
#define repe(i, start, end) for (auto i = (start); (i) <= (end); (i)++)
using ll = long long;
ll floor_sqrt(ll x)
{
ll y = sqrt(x);
while (y * y > x)
y--;
while ((y + 1) * (y + 1) <= x)
y++;
return y;
}
// ======================================== //
int main()
{
int T;
cin >> T;
vector<ll> pow10(11, 1);
rep(i, 1, 11) pow10[i] = pow10[i - 1] * 10;
auto solve = [&]() -> ll
{
ll C, D;
cin >> C >> D;
ll ans = 0;
repe(k, 1, 10)
{
ll l_x = max<ll>(1, pow10[k - 1] - C);
ll r_x = min<ll>(D, pow10[k] - 1 - C);
if (l_x > r_x)
continue;
ll l_val = pow10[k] * C + C + l_x;
ll r_val = pow10[k] * C + C + r_x;
ans += floor_sqrt(r_val) - floor_sqrt(l_val - 1);
}
return ans;
};
while (T--)
{
cout << solve() << endl;
}
return 0;
}
Submission Info
| Submission Time | |
|---|---|
| Task | D - 183184 |
| User | Yuulis |
| Language | C++ 23 (gcc 12.2) |
| Score | 400 |
| Code Size | 1134 Byte |
| Status | AC |
| Exec Time | 447 ms |
| Memory | 3620 KiB |
Judge Result
| Set Name | Sample | All | ||||
|---|---|---|---|---|---|---|
| Score / Max Score | 0 / 0 | 400 / 400 | ||||
| Status |
|
|
| Set Name | Test Cases |
|---|---|
| Sample | 00-sample-01.txt |
| All | 00-sample-01.txt, 01-01.txt, 01-02.txt, 01-03.txt, 01-04.txt, 01-05.txt, 01-06.txt, 01-07.txt, 01-08.txt, 01-09.txt |
| Case Name | Status | Exec Time | Memory |
|---|---|---|---|
| 00-sample-01.txt | AC | 1 ms | 3444 KiB |
| 01-01.txt | AC | 410 ms | 3548 KiB |
| 01-02.txt | AC | 413 ms | 3428 KiB |
| 01-03.txt | AC | 447 ms | 3456 KiB |
| 01-04.txt | AC | 439 ms | 3480 KiB |
| 01-05.txt | AC | 413 ms | 3520 KiB |
| 01-06.txt | AC | 395 ms | 3620 KiB |
| 01-07.txt | AC | 424 ms | 3520 KiB |
| 01-08.txt | AC | 403 ms | 3552 KiB |
| 01-09.txt | AC | 435 ms | 3568 KiB |