QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#735565 | #9705. Multiply | rose_DKY# | TL | 0ms | 3604kb | C++20 | 886b | 2024-11-11 20:45:19 | 2024-11-11 20:45:19 |
Judging History
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...