Submission #70304209
Source Code Expand
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <deque>
#include <queue>
#include <numeric>
#include <stack>
#include <cassert>
#include <cstring>
#include <cmath>
#include <random>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <chrono>
#include <sstream>
#include <limits>
#include <functional>
using namespace std;
#define endl '\n'
// #define LOCAL
using int64 = int64_t;
using uint64 = unsigned long long;
using int128 = __int128_t;
#ifdef LOCAL
#include "src/debug.h"
#else
#define debug(...) 42
#endif
int64 C, D;
int64 flSqrt(int64 x) {
int64 y = sqrt(x);
while (y * y > x) y--;
while ((y + 1) * (y + 1) <= x) y++;
return y;
}
void solve() {
cin >> C >> D;
int64 ans = 0;
int64 xmin = 1, xmax = 9, k = 10;
while (xmin <= C + D) {
int64 l = max(xmin, C + 1);
int64 r = min(xmax, C + D);
if (l <= r) {
int64 candL = C * k + l, candR = C * k + r;
ans += flSqrt(candR) - flSqrt(candL - 1);
}
xmin *= 10;
xmax = xmax * 10 + 9;
k *= 10;
}
cout << ans << endl;
}
signed main() {
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
int T;
cin >> T;
while (T--) {
solve();
}
return 0;
}
Submission Info
| Submission Time | |
|---|---|
| Task | D - 183184 |
| User | therealchainman |
| Language | C++ 20 (gcc 12.2) |
| Score | 400 |
| Code Size | 1403 Byte |
| Status | AC |
| Exec Time | 53 ms |
| Memory | 3444 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 | 3372 KiB |
| 01-01.txt | AC | 51 ms | 3424 KiB |
| 01-02.txt | AC | 52 ms | 3384 KiB |
| 01-03.txt | AC | 47 ms | 3332 KiB |
| 01-04.txt | AC | 50 ms | 3368 KiB |
| 01-05.txt | AC | 53 ms | 3292 KiB |
| 01-06.txt | AC | 47 ms | 3420 KiB |
| 01-07.txt | AC | 50 ms | 3444 KiB |
| 01-08.txt | AC | 50 ms | 3420 KiB |
| 01-09.txt | AC | 53 ms | 3440 KiB |