QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#790028 | #9738. Make It Divisible | qfl_zzz# | WA | 0ms | 3824kb | C++23 | 1.4kb | 2024-11-27 23:44:48 | 2024-11-27 23:44:49 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
#define vv vector
#define ll long long
const int N = 200000 + 5;
const int P = 1e9 + 7;
const ll inf = 1e18;
mt19937_64 gen(chrono::steady_clock::now().time_since_epoch().count());
uniform_int_distribution<ll> rd(0, 1e9);
inline ll rnd() { return rd(gen); }
void qfl_zzz()
{
ll n, k;
cin >> n >> k;
vv<ll> a(n + 1);
for (ll i = 1; i <= n; ++i)
cin >> a[i];
sort(a.begin() + 1, a.end());
if (n == 1)
{
cout << k << " " << k * (k + 1) / 2 << "\n";
return;
}
ll g = 0;
for (ll i = 2; i <= n; ++i)
g = __gcd(g, a[i] - a[i - 1]);
set<ll> s;
auto upd = [&](ll d)
{
ll x = d - a[1];
if (1 <= x && x <= k)
s.insert(x);
};
for (ll i = 1; i * i <= g; ++i)
if (g % i == 0)
{
upd(i);
if (i * i != g)
upd(g / i);
}
ll cnt = 0, sum = 0;
for (ll x : s)
++cnt, sum += x;
cout << cnt << " " << sum << "\n";
}
int main()
{
ios::sync_with_stdio(false);
cin.tie(0), cout.tie(0);
srand(unsigned(time(0)));
cout << setiosflags(ios::fixed) << setprecision(12);
#ifdef LOCAL
freopen("in.txt", "r", stdin);
freopen("std.txt", "w", stdout);
#endif
int T = 1;
cin >> T;
while (T--)
qfl_zzz();
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3616kb
input:
3 5 10 7 79 1 7 1 2 1000000000 1 2 1 100 1000000000
output:
3 8 0 0 100 5050
result:
ok 3 lines
Test #2:
score: -100
Wrong Answer
time: 0ms
memory: 3824kb
input:
4 201 1000000000 1 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5...
output:
0 0 1 1 0 0 0 0
result:
wrong answer 2nd lines differ - expected: '0 0', found: '1 1'