QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#739837 | #9738. Make It Divisible | remain11 | WA | 1ms | 7720kb | C++20 | 1.6kb | 2024-11-12 23:23:27 | 2024-11-12 23:23:32 |
Judging History
你现在查看的是最新测评结果
- [2024-11-27 18:44:44]
- hack成功,自动添加数据
- (/hack/1263)
- [2024-11-14 09:10:13]
- hack成功,自动添加数据
- (/hack/1178)
- [2024-11-12 23:23:27]
- 提交
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], cnt[maxn];
void solve() {
ll n, k;
cin >> n >> k;
for (int i = 1; i <= n; i++) {
cin >> a[i];
b[i] = a[i];
}
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);
int t=1;
cin>>t;
while (t--) {
solve();
}
return 0;
}
詳細信息
Test #1:
score: 100
Accepted
time: 1ms
memory: 7720kb
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: 5736kb
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'