QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#783715 | #9738. Make It Divisible | 5720226849 | Compile Error | / | / | C++14 | 2.2kb | 2024-11-26 11:30:30 | 2024-11-26 11:30:30 |
Judging History
你现在查看的是最新测评结果
- [2024-11-27 18:44:44]
- hack成功,自动添加数据
- (/hack/1263)
- [2024-11-26 11:30:30]
- 评测
- 测评结果:Compile Error
- 用时:0ms
- 内存:0kb
- [2024-11-26 11:30:30]
- 提交
answer
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define endl '\n'
const ll inf = 1e17;
const ll mod = 998244353;
vector<ll> get_divisors(ll n) {
ll limit = 0;
vector<ll> result;
limit = floor(sqrt(n));
for (ll i = 1; i <= limit; ++i)
if (n % i == 0)
result.push_back(i);
for (ll i = (ll)result.size() - 1; i >= 0; --i)
if (result[i] * result[i] < n)
result.push_back(n / result[i]);
return result;
}
void oper(ll testcase) {
ll n = 0, k = 0, sum = 0;
bool has_valid_x = false;
cin >> n >> k;
vector<ll> a(n);
for (ll i = 0; i < n; ++i)
cin >> a[i];
vector<ll> prefix_diff_gcd(n);
prefix_diff_gcd[0] = 0;
for (ll i = 1; i < n; ++i)
prefix_diff_gcd[i] = gcd(prefix_diff_gcd[i - 1], abs(a[i] - a[i - 1]));
vector<ll> valid_x;
for (ll i = 1; i < n; ++i) {
vector<ll> current_valid_x;
if (a[i] == a[i - 1])
continue;
for (ll divisor : get_divisors(abs(a[i] - a[i - 1]))) {
ll x = 0;
x = divisor - a[i - 1];
if (x >= 1 && x <= k && (a[i] + x) % (a[i - 1] + x) == 0)
current_valid_x.push_back(x);
}
for (ll divisor : get_divisors(gcd(prefix_diff_gcd[i - 1], abs(a[i] - a[i - 1])))) {
ll x = 0;
x = divisor - a[i];
if (x >= 1 && x <= k && (a[i - 1] + x) % (a[i] + x) == 0)
current_valid_x.push_back(x);
}
if (has_valid_x)
valid_x.resize(set_intersection(valid_x.begin(), valid_x.end(), current_valid_x.begin(), current_valid_x.end(), valid_x.begin()) - valid_x.begin());
else {
valid_x = current_valid_x;
has_valid_x = true;
}
}
if (has_valid_x) {
for (ll x : valid_x)
sum += x;
cout << valid_x.size() << ' ' << sum;
} else
cout << k << ' ' << k * (k + 1) / 2;
cout << '\n';
}
int main() {
ios::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);
ll ttt = 1;
cin >> ttt;
for (ll i = 1; i <= ttt; i++) {
oper(i);
}
}
Details
answer.code: In function ‘void oper(ll)’: answer.code:32:30: error: ‘gcd’ was not declared in this scope 32 | prefix_diff_gcd[i] = gcd(prefix_diff_gcd[i - 1], abs(a[i] - a[i - 1])); | ^~~ answer.code:44:40: error: ‘gcd’ was not declared in this scope 44 | for (ll divisor : get_divisors(gcd(prefix_diff_gcd[i - 1], abs(a[i] - a[i - 1])))) { | ^~~