| Task: | Toistot |
| Sender: | Metabolix |
| Submission time: | 2025-12-20 17:46:13 +0200 |
| Language: | C++ (C++20) |
| Status: | READY |
| Result: | 63 |
| group | verdict | score |
|---|---|---|
| #1 | ACCEPTED | 11 |
| #2 | ACCEPTED | 21 |
| #3 | ACCEPTED | 31 |
| #4 | WRONG ANSWER | 0 |
| test | verdict | time | group | |
|---|---|---|---|---|
| #1 | ACCEPTED | 0.01 s | 1, 2, 3, 4 | details |
| #2 | ACCEPTED | 0.01 s | 2, 3, 4 | details |
| #3 | ACCEPTED | 0.01 s | 3, 4 | details |
| #4 | WRONG ANSWER | 0.01 s | 4 | details |
| #5 | ACCEPTED | 0.01 s | 1, 2, 3, 4 | details |
| #6 | WRONG ANSWER | 0.01 s | 4 | details |
Compiler report
input/code.cpp: In function 'll solve(ll, ll, int)':
input/code.cpp:39:29: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
39 | if (to_string(b).size() < rep) {
| ~~~~~~~~~~~~~~~~~~~~^~~~~Code
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
vector<vector<ll>> mul = {
{0},
{0, 1, 11, 111, 1111, 11111, 111111, 1111111, 11111111, 111111111, 1111111111L, 11111111111L, 111111111111L, 1111111111111L, 11111111111111L, 111111111111111L, 1111111111111111L, 11111111111111111L, 111111111111111111L, 1111111111111111111L},
{0, 1, 101, 10101, 1010101, 101010101L, 10101010101L, 1010101010101L, 101010101010101L, 10101010101010101L},
{0, 1, 1001, 1001001, 1001001001L, 1001001001001L, 100100100100100L},
{0, 1, 10001, 100010001, 1000100010001L},
{0, 1, 100001, 10000100001L},
{0, 1, 1000001, 1000001000001L},
{0, 1, 10000001},
{0, 1, 100000001},
{0, 1, 1000000001},
};
string tee_max_pala(ll x, int rep) {
string s = to_string(x);
if (s.size() % rep == 0) {
return s.substr(0, s.size() / rep);
} else {
return string(s.size() / rep, '9');
}
}
string tee_min_pala(ll x, int rep) {
string s = to_string(x);
if (s.size() % rep == 0) {
return s.substr(0, s.size() / rep);
} else {
return '1' + string(s.size() / rep, '0');
}
}
ll solve(ll a, ll b, int rep) {
if (to_string(b).size() < rep) {
return 0;
}
string min_pala = tee_min_pala(a, rep);
string max_pala = tee_max_pala(b, rep);
ll min_i = stol(min_pala);
ll max_i = stol(max_pala);
if (max_i * mul[max_pala.size()][rep] > b) {
max_i -= 1;
}
if (min_i * mul[min_pala.size()][rep] < a) {
min_i += 1;
}
ll num = (max_i >= min_i ? max_i + 1 - min_i : 0);
return num;
}
// ll laske(ll a, ll b, int rep,)
int main() {
ios::sync_with_stdio(false);
cin.tie(0);
int good_reps[] = {2, 3, 5, 7};
int bad_reps[] = {6, 10, 14, 15};
int t;
cin >> t;
for (int i = 0; i < t; ++i) {
ll a, b;
cin >> a >> b;
ll ret = 0;
for (int rep: good_reps) {
ret += solve(a, b, rep);
}
for (int rep: bad_reps) {
ret -= solve(a, b, rep);
}
cout << ret << endl;
}
return 0;
}
Test details
Test 1
Group: 1, 2, 3, 4
Verdict: ACCEPTED
| input |
|---|
| 1000 633 906 727 914 585 884 750 792 ... |
| correct output |
|---|
| 3 2 2 1 0 ... |
| user output |
|---|
| 3 2 2 1 0 ... |
Test 2
Group: 2, 3, 4
Verdict: ACCEPTED
| input |
|---|
| 1000 647761 927345 744364 840268 598715 905836 767448 810881 ... |
| correct output |
|---|
| 303 105 333 48 95 ... |
| user output |
|---|
| 303 105 333 48 95 ... |
Test 3
Group: 3, 4
Verdict: ACCEPTED
| input |
|---|
| 1000 663307073 949601845 762227828 860434499 613084013 927576203 785866095 830342436 ... |
| correct output |
|---|
| 286 98 314 44 89 ... |
| user output |
|---|
| 286 98 314 44 89 ... |
Test 4
Group: 4
Verdict: WRONG ANSWER
| input |
|---|
| 1000 818435896335669158 98300938101... |
| correct output |
|---|
| 164737893 96015818 103821980 402263734 52636276 ... |
| user output |
|---|
| 164737893 96015818 103821979 402263734 52636275 ... |
Feedback: Incorrect character on line 3 col 8: expected "103821980", got "103821979"
Test 5
Group: 1, 2, 3, 4
Verdict: ACCEPTED
| input |
|---|
| 990 1 1 1 2 1 3 1 4 ... |
| correct output |
|---|
| 0 0 0 0 0 ... |
| user output |
|---|
| 0 0 0 0 0 ... |
Test 6
Group: 4
Verdict: WRONG ANSWER
| input |
|---|
| 961 1 1000000000000000000 1 999999999999999999 1 999999999999999998 1 999999999999999997 ... |
| correct output |
|---|
| 1001000097 1001000097 1001000096 1001000096 1001000096 ... |
| user output |
|---|
| 1001000070 1001000070 1001000068 1001000068 1001000068 ... |
Feedback: Incorrect character on line 1 col 9: expected "1001000097", got "1001000070"
