QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#591622 | #7797. Based Zeros | StrausKoldun | WA | 240ms | 3848kb | C++17 | 1.4kb | 2024-09-26 16:50:48 | 2024-09-26 16:50:49 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
vector<long long> bases;
void prep() {
bases.reserve(78498);
for (int i = 2; i < 1e6 + 1; i++)
{
// cout << i << endl;
bool t = false;
for (auto j : bases)
{
if(1LL*j*j > i){
break;
}
t |= (i % j) == 0;
if(t) break;
}
if(!t){
// cout << i << '\n';
bases.push_back(i);
}
}
}
void solve() {
int n;
cin >> n;
auto foo = [](int n, int base) {
int res = 0;
int chis = 0;
while (n != 0)
{
res += (n % base) == 0;
chis++;
n /= base;
}
return make_pair(res, chis);
};
pair<int, vector<long long>> ans = {0, {}};
for (int i = 2; i <= 1e6; i++)
{
auto [del, chis] = foo(n, i);
if(chis < ans.first){
break;
}
if (ans.first == del) {
ans.second.push_back(i);
continue;
}
if (ans.first < del) {
ans = {del, {i}};
continue;
}
}
if(ans.first == 1 && n >= 1e6){
ans.second.push_back(n);
}
cout << ans.first << " " << ans.second.size() << '\n';
for (auto i : ans.second) {
cout << i << ' ';
}
cout << '\n';
}
int main() {
ios_base::sync_with_stdio(false);
cin.tie(0);
// prep();
// cout << bases.size() << '\n';
int t = 1;
cin >> t;
while (t--) {
solve();
}
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 4ms
memory: 3592kb
input:
3 11 1007 239
output:
1 3 2 3 11 2 2 3 10 1 4 2 6 15 239
result:
ok 15 numbers
Test #2:
score: 0
Accepted
time: 2ms
memory: 3628kb
input:
1 2
output:
1 1 2
result:
ok 3 number(s): "1 1 2"
Test #3:
score: 0
Accepted
time: 2ms
memory: 3552kb
input:
10 56 20 6 84 25 20 60 73 70 50
output:
3 1 2 3 1 2 1 3 2 3 6 4 1 2 2 2 2 5 3 1 2 2 2 2 3 4 1 2 4 1 2 3 1 2
result:
ok 34 numbers
Test #4:
score: 0
Accepted
time: 2ms
memory: 3848kb
input:
100 6211 4783 6225 5664 9709 5455 5424 7394 2329 3880 8260 950 2604 1366 3080 5505 4983 9595 6563 2697 2249 675 1537 5884 6070 2905 3137 5675 8138 1626 5348 8876 6065 8454 9346 3421 8857 8941 2743 9343 6201 45 1651 8575 5327 2577 4553 7595 1185 8775 7241 616 4465 3642 1657 5791 2800 1669 9307 2640 6...
output:
8 1 2 5 1 2 8 1 2 9 1 2 5 1 2 5 1 2 8 1 2 6 1 2 7 1 2 6 1 2 11 1 2 3 1 2 7 1 2 5 1 2 9 1 2 8 1 2 4 1 2 5 1 2 7 1 3 7 1 2 7 1 2 5 1 2 8 1 2 4 1 2 4 1 2 5 1 2 8 1 2 6 1 2 4 1 2 5 1 2 7 1 2 8 1 2 5 1 2 10 1 2 10 1 2 4 1 2 8 1 2 6 1 2 4 1 2 5 1 2 7 1 2 2 2 2 3 4...
result:
ok 309 numbers
Test #5:
score: 0
Accepted
time: 1ms
memory: 3572kb
input:
1000 461349 350342 809551 211152 572968 896101 718511 44614 72871 106360 141199 858436 576392 414585 897161 917037 679916 987675 507878 851589 62793 717573 119037 587678 774831 977964 313698 208868 953676 26986 273250 625834 573172 865274 105345 290197 807126 566514 193786 645978 670847 961765 72414...
output:
11 1 2 11 1 2 9 1 2 10 1 2 11 1 2 9 1 2 6 1 2 8 1 2 8 1 2 6 1 2 8 1 2 12 1 2 12 1 2 8 1 2 11 1 2 6 1 2 7 1 2 10 1 2 4 2 2 3 8 1 2 7 1 2 10 1 2 6 1 2 7 1 2 7 1 2 9 1 2 11 1 2 7 1 2 10 1 2 7 1 2 11 1 2 11 1 2 8 1 2 7 1 2 9 1 2 9 1 2 11 1 2 11 1 2 6 1 2 8 1 2 7 1...
result:
ok 3016 numbers
Test #6:
score: 0
Accepted
time: 1ms
memory: 3576kb
input:
1000 777059002 567106059 388668775 167791212 42381512 49672608 177050808 261845460 149382624 99056475 130881775 525176452 534623620 238537726 967742710 365633758 326600673 670402852 581698924 947942987 925388803 294998730 302063477 209655322 871274865 966051641 105266482 685127231 675409437 29302600...
output:
13 1 2 16 1 2 12 1 2 19 1 2 16 1 2 12 1 2 15 1 2 11 2 2 3 14 1 2 8 1 2 10 1 2 14 1 2 11 1 2 8 1 2 12 1 2 14 1 2 12 1 2 15 1 2 18 1 2 17 1 2 19 1 2 16 1 2 16 1 2 13 1 2 12 1 2 14 1 2 14 1 2 13 1 2 16 1 2 10 1 2 14 1 2 16 1 2 13 1 2 13 1 2 15 1 2 14 1 2 14 1 2 13 1...
result:
ok 3004 numbers
Test #7:
score: -100
Wrong Answer
time: 240ms
memory: 3564kb
input:
1000 279846554360 412045752288 342314468812 980743511493 147529260079 909385413888 9636990671 164548629171 115893886661 895700506608 125295918330 957773182610 770786835718 872163538712 414411444790 224773301658 292973214787 413597032696 791272938821 692413707694 335697403673 946050452282 23425062727...
output:
3 2 3 6 3 2 3 6 3 2 3 6 3 2 3 6 3 2 3 6 3 2 3 6 3 2 3 6 3 2 3 6 3 2 3 6 3 2 3 6 3 2 3 6 3 2 3 6 3 2 3 6 3 2 3 6 3 2 3 6 3 2 3 6 3 2 3 6 3 2 3 6 3 2 3 6 3 2 3 6 3 2 3 6 3 2 3 6 3 2 3 6 3 2 3 6 3 2 3 6 3 2 3 6 3 2 3 6 3 2 3 6 3 2 3 6 3 2 3 6 3 2 3 6 3 2 3 6 3 2 3 6 3 2...
result:
wrong answer 1st numbers differ - expected: '23', found: '3'