Submission #51500972
Source Code Expand
#include <bits/stdc++.h>
using namespace std;
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
#define pb push_back
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
int digits(ll n) {
int ret = 0;
while (n != 0) {
++ret;
n /= 10;
}
return ret;
}
int main() {
cin.tie(0)->sync_with_stdio(0);
int TESTS; cin >> TESTS;
while (TESTS--) {
ll n; cin >> n;
ll ans = 1;
int d = digits(n);
int yd = (d - 1) / 2 + 1;
ll a = 100, b = 10;
for (int i = 2; i <= yd + 1; ++i) {
if (a - 2 * b <= n) {
++ans;
}
ans += max(min(a + b - 1, n) - (a - b) + 1, 0LL);
a *= 100LL;
b *= 10LL;
}
cout << ans << "\n";
}
}
Submission Info
| Submission Time | |
|---|---|
| Task | D - Digit vs Square Root |
| User | richzli |
| Language | C++ 20 (gcc 12.2) |
| Score | 500 |
| Code Size | 918 Byte |
| Status | AC |
| Exec Time | 17 ms |
| Memory | 3592 KiB |
Judge Result
| Set Name | Sample | All | ||||
|---|---|---|---|---|---|---|
| Score / Max Score | 0 / 0 | 500 / 500 | ||||
| Status |
|
|
| Set Name | Test Cases |
|---|---|
| Sample | sample_01.txt |
| All | sample_01.txt, test_01.txt, test_02.txt, test_03.txt, test_04.txt, test_05.txt, test_06.txt, test_07.txt |
| Case Name | Status | Exec Time | Memory |
|---|---|---|---|
| sample_01.txt | AC | 1 ms | 3440 KiB |
| test_01.txt | AC | 1 ms | 3500 KiB |
| test_02.txt | AC | 10 ms | 3592 KiB |
| test_03.txt | AC | 17 ms | 3448 KiB |
| test_04.txt | AC | 11 ms | 3460 KiB |
| test_05.txt | AC | 17 ms | 3592 KiB |
| test_06.txt | AC | 12 ms | 3588 KiB |
| test_07.txt | AC | 14 ms | 3452 KiB |