QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#662323#9248. An Easy Math Problem123BVNWA 0ms3876kbC++23963b2024-10-20 22:52:312024-10-20 22:52:32

Judging History

This is the latest submission verdict.

  • [2024-10-31 22:36:43]
  • hack成功,自动添加数据
  • (/hack/1098)
  • [2024-10-31 22:13:58]
  • hack成功,自动添加数据
  • (/hack/1096)
  • [2024-10-31 22:00:43]
  • hack成功,自动添加数据
  • (/hack/1095)
  • [2024-10-20 22:52:32]
  • Judged
  • Verdict: WA
  • Time: 0ms
  • Memory: 3876kb
  • [2024-10-20 22:52:31]
  • Submitted

answer

#include<bits/stdc++.h>
#define int long long
using namespace std;
map<int, int>mp;
void solve() {
	int n,m;
	cin >> n;
	m = n;
	if (mp[n]) {
		cout << mp[n] << endl;
		return;
	}
	vector<int>v;
	for (int i = 2; i <= n / i; i++) {
		int cnt = 0;
		while (n % i == 0) {
			cnt++;
			n /= i;
		}
		v.push_back(cnt);
	}
	if (n > 1)v.push_back(1);
	n = 2;
	for (int i = 1; i < v.size(); i++) {
		n *= 2;
	}
	int ans = 1;
	int op = 1;
	for (int j = 0; j < v.size(); j++)op *= (v[j] + 1);
	for (int i = 0; i < min(2000ll,n); i++) {
		int x = i;
		int pos1 = 1, pos2 = op;
		int cnt = 0,j=0;
		while (x&&j<v.size()) {
			if (x % 2)pos1 *= v[j], pos2 /= (v[j] + 1);
			x /= 2;
			j++;
		}
		ans += pos1 * pos2;
	}
	mp[m] = ans / 2;
	cout << ans / 2 << "\n";
}
signed main() {
	std::ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int _ = 1;
	cin >> _;
	while (_--) {
		solve();
	}//ut << _<<endl;
	return 0;
}

详细

Test #1:

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

input:

10
1
2
3
4
5
6
7
8
9
10

output:

1
2
2
3
2
5
2
4
3
5

result:

ok 10 lines

Test #2:

score: -100
Wrong Answer
time: 0ms
memory: 3844kb

input:

2000
6469693230
6469693230
6469693230
6469693230
6469693230
6469693230
6469693230
6469693230
6469693230
6469693230
6469693230
6469693230
6469693230
6469693230
6469693230
6469693230
6469693230
6469693230
6469693230
6469693230
6469693230
6469693230
6469693230
6469693230
6469693230
6469693230
646969323...

output:

3888
3888
3888
3888
3888
3888
3888
3888
3888
3888
3888
3888
3888
3888
3888
3888
3888
3888
3888
3888
3888
3888
3888
3888
3888
3888
3888
3888
3888
3888
3888
3888
3888
3888
3888
3888
3888
3888
3888
3888
3888
3888
3888
3888
3888
3888
3888
3888
3888
3888
3888
3888
3888
3888
3888
3888
3888
3888
3888
3888
...

result:

wrong answer 1st lines differ - expected: '29525', found: '3888'