QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#371223#7797. Based ZerosFOY#WA 0ms3568kbC++171.4kb2024-03-30 02:31:142024-03-30 02:31:16

Judging History

你现在查看的是最新测评结果

  • [2024-03-30 02:31:16]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3568kb
  • [2024-03-30 02:31:14]
  • 提交

answer

#include<bits/stdc++.h>

using namespace std;
using ull = unsigned long long;

const ull MAX = 1000;

ull pow(ull base, ull exp) {
	ull out = 1;
	for (ull i = 0; i < exp; i++) {
		out *= base;
	}

	return out;
}

pair<ull, ull> cntZ(ull n, ull b) {
	ull out = 0;
	ull bits = 0;
	while (n) {
		if (n%b == 0) out++;
		n /= b;
		bits++;
	}
	return { out, bits };
}

map<ull, pair<ull, ull>> ans;
map<ull, vector<ull>> memo;

void solve() {
	ull n;
	cin >> n;

	if (ans.count(n) != 0) {
		cout << ans[n].first << " " << ans[n].second;
		for (ull b : memo[n]) {
			cout << b << " ";
		}
		cout << endl;
		
		return;
	}

	ull max_zeros = 0;
	vector<ull> res;
	for (ull b = 2; b <= MAX && b <= n; b++) {
		pair<ull, ull> cnt = cntZ(n, b);

		if (cnt.first > max_zeros) {
			res.clear();
			res.push_back(b);
			max_zeros = cnt.first;
		} else if (cnt.first == max_zeros) {
			res.push_back(b);
		}
	}

	for (ull b = MAX + 1; pow(b, max_zeros) <= n; b++) {
		pair<ull, ull> cnt = cntZ(n, b);

		if (cnt.first > max_zeros) {
			res.clear();
			res.push_back(b);
			max_zeros = cnt.first;
		} else if (cnt.first == max_zeros) {
			res.push_back(b);
		}
	}

	ans[n] = make_pair(max_zeros, res.size());
	memo[n] = res;

	cout << max_zeros << " " << res.size() << endl;
	for (ull c : res) {
		cout << c << " ";
	}
	cout << endl;
}

signed main() {
	ull t;
	cin >> t;

	while (t--) solve();
}

詳細信息

Test #1:

score: 100
Accepted
time: 0ms
memory: 3512kb

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: 3568kb

input:

1
2

output:

1 1
2 

result:

ok 3 number(s): "1 1 2"

Test #3:

score: -100
Wrong Answer
time: 0ms
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 12 
2 2
2 3 
4 1
2 
4 1
2 
3 1
2 

result:

wrong answer 20th numbers differ - expected: '1', found: '12'