QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#735565#9705. Multiplyrose_DKY#TL 0ms3604kbC++20886b2024-11-11 20:45:192024-11-11 20:45:19

Judging History

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

  • [2024-11-11 20:45:19]
  • 评测
  • 测评结果:TL
  • 用时:0ms
  • 内存:3604kb
  • [2024-11-11 20:45:19]
  • 提交

answer

#include<bits/stdc++.h>
typedef long long ll;
using namespace std;
#define endl "\n"
#define MAXN 200005
ll a[MAXN];
void solve()
{
	ll n, x, y;
	cin >> n >> x >> y;
	
	for (int i = 1; i <= n; i++) {
		cin >> a[i];
	}
	
	ll p = 0, c = 0;
	for (ll i = 2; i <= x / i; i++) {
		if (x % i == 0) {
			ll s = 0;
			while (x % i == 0) {
				x /= i;
			}
			if (i > p) {
				p = i;
				c = s;
			}
		}
	}
	if (x != 1) {
		if (x > p) {
			p = x;
			c = 1;
		}
	}
	
	ll c1 = 0, c2 = 0;
	for (int i = 1; i <= n; i++) {
		while (a[i]) {
			c1 += a[i] / p;
			a[i] /= p;
		}
	}
	while (y) {
		c2 += y / x;
		y /= x;
	}
	
	cout << (c2 - c1) / c << endl;
}
int main()
{
	
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	
	int t = 1;
	cin >> t;
	while (t--) {
		solve();
	}
	
	return 0;
}
/*
2
3 10 10
2 3 4
2 2 10
1 1
 */

詳細信息

Test #1:

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

input:

2
3 10 10
2 3 4
2 2 10
1 1

output:

2
8

result:

ok 2 number(s): "2 8"

Test #2:

score: -100
Time Limit Exceeded

input:

8
929 98210021061137 164832982985885580
43576998167336 157303878397705 212661169553039 169068044677212 17733912750082 101059786177542 56528418806042 170741049344189 128297164019222 208810463591190 96264177952672 70816863413347 116985928070432 56330014332760 10006522486360 110959002803542 15298525649...

output:


result: