QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#750227 | #9738. Make It Divisible | Susie_Rain# | WA | 1ms | 5768kb | C++20 | 2.0kb | 2024-11-15 13:33:08 | 2024-11-15 13:33:09 |
Judging History
answer
#include<bits/stdc++.h>
#include<queue>
#include<string.h>
#include<iostream>
#include<map>
#include<vector>
#include<algorithm>
#define int long long
#define ll long long
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define nl t[n].l
#define nr t[n].r
#define gcd __gcd
#define itn int
#define db long double
using namespace std;
const int maxn=1e6+50;
const int inf=4e18+10;
const int INF=2e18;
const int mod=998244353;
const db eps=1e-8;
const db pi=acos(-1.0);
#define pop_count __builtin_popcountll
itn a[maxn];
itn vis[maxn];
void solve()
{
int n,k;
cin>>n>>k;
rep(i,0,10000) vis[i]=0;
rep(i,1,n)
{
cin>>a[i];
}
bool f=true;
rep(i,2,n)
{
if(a[i]!=a[i-1])
{
f=false;
}
}
if(f)
{
cout<<k<<' '<<k*(k+1)/2<<'\n';
return;
}
int ok=0;
vector<int> g;
rep(i,2,n)
{
int x=a[i-1],y=a[i];
if(x==y) continue;
if(x>y) swap(x,y);
if(!ok)
{
y-=x;
for(int j=1;j*j<=y;j++)
{
if(y%j==0)
{
if(j-x>=1&&j-x<=k) g.push_back(j-x);
if(j!=y/j)
{
if(y/j-x>=1&&y/j-x<=k)
{
g.push_back(y/j-x);
}
}
}
}
ok=1;
}
else{
rep(j,0,(int)g.size()-1)
{
if((y+g[j])%(x+g[j])!=0)
{
vis[j]=1;
}
}
}
}
int ans=0,cnt=0;
rep(i,0,(int)g.size()-1)
{
if(vis[i]) continue;
cnt++;
ans+=g[i];
}
cout<<cnt<<' '<<ans<<'\n';
}
signed main()
{
ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
int __=1;
//srand((time(0)));
cin>>__;
while(__--)
{
solve();
}
return 0;
}
详细
Test #1:
score: 100
Accepted
time: 1ms
memory: 5768kb
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: 5672kb
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'