QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#864985 | #9738. Make It Divisible | xjt05 | WA | 0ms | 5864kb | C++23 | 2.3kb | 2025-01-21 12:56:59 | 2025-01-21 12:56:59 |
Judging History
answer
#include<iostream>
#include<queue>
#include<map>
#include<set>
#include<vector>
#include<algorithm>
#include<deque>
#include<cctype>
#include<string.h>
#include<math.h>
#include<time.h>
#include<random>
#include<stack>
#include<string>
//#include<bits/stdc++.h>
#include <unordered_map>
#define ll long long
#define lowbit(x) (x & -x)
#define endl "\n"// 交互题记得删除
using namespace std;
mt19937 rnd(time(0));
const ll mod = 998244353;
//const ll p=rnd()%mod;
ll ksm(ll x, ll y)
{
ll ans = 1;
while (y)
{
if (y & 1)
{
ans = ans % mod * (x % mod) % mod;
}
x = x % mod * (x % mod) % mod;
y >>= 1;
}
return ans % mod % mod;
}
ll gcd(ll x, ll y)
{
if (y == 0)
return x;
else
return gcd(y, x % y);
}
void fio()
{
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
}
ll a[650000];
ll b[650000];
set<pair<ll,ll>>p;
set<ll>q;
vector<ll>op;
int main()
{
fio();
ll t;
cin>>t;
while(t--)
{
op.clear();
q.clear();
p.clear();
ll n,f;
cin>>n>>f;
ll gs=0;
for(ll i=1;i<=n;i++)
{
cin>>a[i];
if(a[i]==a[1])
gs++;
}
if(gs==n)
{
cout<<f<<" "<<(1+f)*f/2<<endl;
continue;
}
set<ll>q;
ll ko=0;
ll zk,zr;
for(ll i=1;i<n;i++)
{
ll l=a[i],r=a[i+1];
if(l>r)
swap(l,r);
if(l==r)continue;
p.insert({l,r});
}
for(auto j:p)
{
ll l=j.first,r=j.second;
//cout<<l<<" "<<r<<endl;
op.clear();
if(ko==0)
{
r-=l;
for(ll u=1;u*u<=r;u++)
{
if(r%u==0)
{
if(u-l>=1&&u-l<=f)
{
q.insert(u-l);
}
if(r/u-l>=1&&r/u-l<=f)
{
q.insert(r/u-l);
}
}
}
ko=1;
//cout<<q.size()<<endl;
}
else
{
//cout<<r<<" "<<l<<endl;
for(auto k:q)
{
//cout<<k<<endl;
if((r+k)%(l+k)==0)
{
continue;
}
else
{
op.push_back(k);
}
}
for(auto k:op)
q.erase(k);
if(q.size()==0)
break;
}
}
ll ans=0;
for(auto j:q)
{
ans+=j;
}
cout<<q.size()<<" "<<ans<<endl;
}
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 5864kb
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: 5668kb
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:
1 1 1 1 1 1 1 1
result:
wrong answer 1st lines differ - expected: '0 0', found: '1 1'