QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#747674#9248. An Easy Math Problemxianjing#TL 3ms3800kbC++23816b2024-11-14 17:50:492024-11-14 17:50:49

Judging History

This is the latest submission verdict.

  • [2024-11-14 17:50:49]
  • Judged
  • Verdict: TL
  • Time: 3ms
  • Memory: 3800kb
  • [2024-11-14 17:50:49]
  • Submitted

answer

#include <bits/stdc++.h>
using namespace std;
#define int long long

void solve(){
	int n,cnt = 0;
	cin >> n;
	vector<int> s;
	for(int i = 2;i <= 1e5;i ++){
		int res = 0;
		while(n % i == 0){
			n /= i;
			res ++;
		}
		if(res) s.push_back(res);
	}
	if(n != 1) s.push_back(1);
	cnt = s.size();
//	cout << cnt << '\n';
	int res = 1,ans = 0;
	auto dfs = [&](auto self,int x) -> void{
		if(x == cnt) {
			ans += res;
			return;
		}
		for(int i = 0;i < 3;i ++){
			if(i != 0){
				res *= s[x];
				self(self,x + 1);
				res /= s[x];
			} else{
				self(self,x + 1);
			}
		}	
	};
	dfs(dfs,0);
//	cout << cnt << " " << ans << '\n';
	ans -= 1;
	ans /= 2;
	ans += 1;
	cout << ans << '\n';
}


signed main(){
	int t = 1;
	cin >> t;
	while(t --){
		solve();
	}
	return 0;
}

详细

Test #1:

score: 100
Accepted
time: 3ms
memory: 3800kb

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
Time Limit Exceeded

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:

29525
29525
29525
29525
29525
29525
29525
29525
29525
29525
29525
29525
29525
29525
29525
29525
29525
29525
29525
29525
29525
29525
29525
29525
29525
29525
29525
29525
29525
29525
29525
29525
29525
29525
29525
29525
29525
29525
29525
29525
29525
29525
29525
29525
29525
29525
29525
29525
29525
29525
...

result: