QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#884023 | #9738. Make It Divisible | XJK404 | WA | 0ms | 9956kb | C++14 | 1.4kb | 2025-02-05 20:55:33 | 2025-02-05 20:55:42 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
#define itn int
#define tin int
#define nit int
#define longlong long long
typedef long long ll;
typedef unsigned long long ull;
ll n,k;
ll a[1145141],cnt,flag,b[1145141],c[1145141],d[114514];
void solve() {
cin>>n>>k;
for(int i=1;i<=n;i++){
cin>>d[i];
}
sort(d+1,d+n+1);
int m=0;
for(int i=1;i<=n;i++){
if(d[i]!=d[i-1]){
m++;
a[m]=d[i];
}
}
n=m;
if(n<=1){
cout<<k<<' '<<k*(k+1)/2<<endl;
return ;
}
cnt=0;
ll cnt2=0;
ll sq=a[2]-a[1];
for(ll j=1;j<=ceil(sqrt(sq));j++){
ll C=sq/j;
if(C*j==sq){
if(C-a[1]>0&&k>=C-a[1]){
cnt2++;
c[cnt2]=C-a[1];
}
if(j-a[1]>0&&k>=j-a[1]){
cnt2++;
c[cnt2]=j-a[1];
}
}
}
sort(c+1,c+cnt2+1);
for(int j=1;j<=cnt2;j++){
if(c[j]!=c[j-1]){
cnt++;
b[cnt]=c[j];
}
}
for(int i=2;i<n;i++){
cnt2=0;
for(int j=1;j<=cnt;j++){
ll mi=a[i],ma=a[i+1];
if((ma+b[j])%(mi+b[j])==0){
cnt2++;
c[cnt2]=b[j];
}
}
cnt=0;
for(int j=1;j<=cnt2;j++){
cnt++;
b[cnt]=c[j];
}
}
cout<<cnt<<' ';
ll ans=0;
for(int i=1;i<=cnt;i++){
ans+=b[i];
}
cout<<ans<<endl;
}
int main() {
ios::sync_with_stdio(false);
cin.tie(0);cout.tie(0);
int T;
T = 1;
cin >> T;
while(T--) {
solve();
}
return 0;
}
/*
4
2 1000000000
1 2
1 100
1000000000
5 100
7 79 1 7 1
6 10000
1 4 10 13 23 33
*/
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 7780kb
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: 0
Accepted
time: 0ms
memory: 9956kb
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 0 0 0 0 0 0
result:
ok 4 lines
Test #3:
score: -100
Wrong Answer
time: 0ms
memory: 7780kb
input:
500 4 1000000000 8 14 24 18 4 1000000000 17 10 18 14 4 1000000000 6 17 19 19 4 1000000000 15 14 15 25 4 1000000000 16 16 5 25 4 1000000000 4 30 20 5 4 1000000000 11 4 23 9 4 1000000000 14 25 13 2 4 1000000000 18 18 1 15 4 1000000000 22 22 22 28 4 1000000000 15 17 17 10 4 1000000000 22 14 13 25 4 100...
output:
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ...
result:
wrong answer 178th lines differ - expected: '1 2', found: '0 0'