QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#591488 | #7797. Based Zeros | StrausKoldun | TL | 0ms | 0kb | C++17 | 955b | 2024-09-26 16:08:07 | 2024-09-26 16:08:07 |
answer
#include <bits/stdc++.h>
using namespace std;
void solve() {
int n;
cin >> n;
auto foo = [](int n, int base)
{
int res = 0;
while (n != 0)
{
res += (n % base) == 0;
n /= base;
}
return res;
};
pair<int, vector<int>> ans = {0, {}};
vector<int> t;
for (int i = 2; i <= 1e6; i++)
{
bool skip = false;
for (auto j : t)
{
skip |= (j * j == i);
}
if(skip)
continue;
t.push_back(i);
auto del = foo(n, i);
if(ans.first == del){
ans.second.push_back(i);
continue;
}
if(ans.first < del){
ans = {del, {i}};
continue;
}
}
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);
int t = 1;
cin >> t;
while (t--) {
solve();
}
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Time Limit Exceeded
input:
3 11 1007 239