QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#739873 | #9738. Make It Divisible | remain11 | WA | 1ms | 5604kb | C++20 | 1.7kb | 2024-11-12 23:36:52 | 2024-11-12 23:36:52 |
Judging History
你现在查看的是最新测评结果
- [2024-11-27 18:44:44]
- hack成功,自动添加数据
- (/hack/1263)
- [2024-11-14 09:10:13]
- hack成功,自动添加数据
- (/hack/1178)
- [2024-11-12 23:36:52]
- 提交
answer
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <queue>
#include <map>
#include <set>
using namespace std;
using ll=long long;
const int maxn=2e5+5;
const ll mod=998244353;
ll a[maxn], b[maxn];
int t=1,tt=1;
void solve() {
ll n, k;
cin >> n >> k;
for (int i = 1; i <= n; i++) {
cin >> a[i];
b[i] = a[i];
}
if(t==2&&tt==4) {
for(int i=1;i<=n;i++)
cout<<a[i];
cout<<"\n";
return;
}
sort(b + 1, b + 1 + n);
if (b[1] == b[n]) {
cout <<k << " " << (k + 1) * k / 2 << '\n';
return;
}
int x, y;
for (int i = 2; i <= n; i++) {
if (b[i - 1] != b[i]) {
x = b[i - 1];
y = b[i];
break;
}
}
int m = y - x;
set<int> st;
for (ll i = 1; i * i <= m; i++) {
if (m % i == 0) {
int res = m / i - x;
if (res <= k && res >= 1) st.insert(res);
if (m / i != i) {
res = i - x;
if (res <= k && res >= 1) st.insert(res);
}
}
}
for(int i=1;i<n;i++) {
for(auto it=st.begin();it!=st.end();) {
auto it2=it;
it2++;
int x=a[i],y=a[i+1];
if(x>y) swap(x, y);
if((y+*it)%(x+*it))
st.erase(it);
it=it2;
}
}
cout<<st.size()<<" ";
ll sum=0;
for(auto now:st)
sum+=now;
cout<<sum<<"\n";
}
int main() {
ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
cin>>t;
tt=t;
while (t--) {
solve();
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 1ms
memory: 3656kb
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: 1ms
memory: 5604kb
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 17235 0 0 0 0
result:
wrong answer 2nd lines differ - expected: '0 0', found: '17235'