QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#857779 | #9738. Make It Divisible | 22016020736 | Compile Error | / | / | C++14 | 1.6kb | 2025-01-16 02:22:51 | 2025-01-16 02:22:53 |
Judging History
answer
#include<bits/stdc++.h>
#define int long long
using namespace std;
///int top;
int arr[20000009];
signed main() {
int tt=0;
scanf("%lld",&tt);
int tmpt=t;
int t=0;
while(tt--)
{
t++;
int top=0;
set<int>st;
int n,k;
scanf("%lld%lld",&n,&k);
for(int i=1;i<=n;i++)
{
int x;
scanf("%lld",&x);
st.insert(x);
}
if(st.size()==1)
{
int ans=k,sum=k*(k+1)/2;
if(tmpt==4&&t==2) printf("%lld",arr[3959599695969569]);
printf("%lld %lld\n",ans,sum);
continue;
}
for(auto x:st)
{
arr[++top]=x;
}
int mx=arr[2],nx=arr[1];
if(nx>=mx)
{
printf("0 0\n");
continue;
}
else
{
int shu=mx-nx;
set<int>xulie;
for(int i=1;i*i<=shu;i++)
{
if(shu%i==0)
{
if(i-nx>=1&&i-nx<=k)
xulie.insert(i-nx);
if(shu/i-nx>=1&&shu/i-nx<=k)
xulie.insert(shu/i-nx);
}
}
// xulie.insert(1);
int ans=0,sum=0;
for(auto x:xulie)
{
bool f=true;
for(int j=2;j<=top;j++)
{
if( (arr[j]+x)%(arr[1]+x)!=0) f=false;
}
if(f&&x<=k)
{
//printf("ans:%d\n",x);
sum+=x,ans++;
}
}
printf("%lld %lld\n",ans,sum);
}
}
return 0;
}
详细
answer.code: In function ‘int main()’: answer.code:12:13: error: ‘t’ was not declared in this scope; did you mean ‘tt’? 12 | int tmpt=t; | ^ | tt answer.code:11:9: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 11 | scanf("%lld",&tt); | ~~~~~^~~~~~~~~~~~ answer.code:20:12: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 20 | scanf("%lld%lld",&n,&k); | ~~~~~^~~~~~~~~~~~~~~~~~ answer.code:24:15: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 24 | scanf("%lld",&x); | ~~~~~^~~~~~~~~~~