QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#661597 | #7797. Based Zeros | ucup-team1001# | WA | 0ms | 3644kb | C++20 | 2.0kb | 2024-10-20 17:01:42 | 2024-10-20 17:01:42 |
Judging History
answer
#include "bits/stdc++.h"
using namespace std;
using i64 = long long;
const i64 mod = 1e9 + 7;
const i64 inf = 1e18;
#define endl '\n'
mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
int coust(i64 x, i64 y) {
i64 t = 0;
i64 left = 0;
while (x) {
t *= y;
t += x % y;
t %= y;
x /= y;
if (t == 0) left++;
}
return left;
}
bool isprime(i64 x) {
if (x == 1)return false;
for (i64 i = 2; i * i <= x; i++) {
if (x % i == 0)return false;
}
return true;
}
i64 getprime(i64 x) {
while (!isprime(x)) {
x++;
}
return x;
}
i64 qp(__int128 a, __int128 b) {
__int128 res = 1;
while (b) {
res *= a;
if (res > 2e18) return 2e18;
b--;
}
return res;
}
int solve(i64 z) {
i64 n;
n = z;
// cin >> n;
int now0 = 1;
vector<i64> ans;
// map<int, vector<i64>> mp;
for (int i = 2; i <= n; i++) {
i64 p = qp(i, now0);
if (p > n)break;
int t = coust(n, i);
if(now0 < t){
now0 = t;
ans.clear();
ans.emplace_back(i);
}
// mp[t].emplace_back(i);
// now0 = max(now0, t);
}
cout << now0 << " " << ans.size()<< endl;
for (auto x:ans) {
cout << x << " ";
}
cout << endl;
return now0;
}
int main() {
ios::sync_with_stdio(false), cin.tie(0);
int t;
cin >> t;
while (t--) {
i64 n;
cin >> n;
solve(n);
}
// cout << solve(1007) << endl;
// int minn = 100000;
// int t =0;
// for (int i = 5e7; i <1e8; i++) {
// int x = solve(i);
// if(x < minn){
// minn = x;
// t = 1;
// }else if(x == minn){
// t++;
// }
//
//// minn = min(minn, solve(i));
//// cerr << i << " " << minn << endl;
// }
// cout << minn << " "<< t << endl;
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 0ms
memory: 3644kb
input:
3 11 1007 239
output:
1 0 2 1 3 1 0
result:
wrong answer 2nd numbers differ - expected: '3', found: '0'