QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#726141 | #7797. Based Zeros | samandarhacker1 | WA | 0ms | 3640kb | C++14 | 1.5kb | 2024-11-08 21:53:31 | 2024-11-08 21:53:33 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
int cntZero(long long n, long long b){
int cnt = 0;
while(n > 0){
cnt += (n % b == 0 ? 1 : 0);
n /= b;
}
return cnt;
}
bool check(long long n, long long b){
int cnt = 0;
while(n > 0){
cnt += (n % b == 0 ? 1 : 0);
n /= b;
if(cnt > 1)return false;
}
return cnt == 1;
}
void solve(){
long long n;
cin >> n;
int cnt0 = cntZero(n, 10);
if(cnt0 > 0){
int mxZero = cnt0;
vector<int> mapping(11);
mapping[10] = cnt0;
for(int i = 2; i <= 9; i++){
int tmp = cntZero(n, i);
mxZero = max(mxZero, tmp);
mapping[i] = tmp;
}
vector<int> ans;
for(int i = 2; i <= 10; i++){
if(mapping[i] == mxZero){
ans.push_back(i);
}
}
cout << mxZero << ' ' << ans.size() << '\n';
for(int i : ans){
cout << i << ' ';
}
}else{
cout << 1 << ' ';
vector<int> ans;
for(int i = 2; i * i <= n; i++){
if(check(n, i))
ans.push_back(i);
}
cout << ans.size() + 1 << '\n';
for(int i : ans)
cout << i << ' ';
cout << n << ' ';
}
cout << '\n';
}
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);cout.tie(0);
int t;
cin >> t;
while(t--){
solve();
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3600kb
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: 0ms
memory: 3640kb
input:
1 2
output:
1 1 2
result:
ok 3 number(s): "1 1 2"
Test #3:
score: -100
Wrong Answer
time: 0ms
memory: 3604kb
input:
10 56 20 6 84 25 20 60 73 70 50
output:
1 3 4 7 56 3 1 2 1 2 2 6 1 5 4 6 7 9 84 1 1 25 3 1 2 2 2 2 3 1 4 3 4 6 73 4 1 2 3 1 2
result:
wrong answer 1st numbers differ - expected: '3', found: '1'