比赛 |
CSP2022普及组 |
评测结果 |
AAAAAAAAAA |
题目名称 |
解密 |
最终得分 |
100 |
用户昵称 |
康尚诚 |
运行时间 |
1.156 s |
代码语言 |
C++ |
内存使用 |
0.00 MiB |
提交时间 |
2022-10-29 15:47:46 |
显示代码纯文本
#include<bits/stdc++.h>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
int main()
{
freopen("csp2022pj_decode.in","r",stdin);
freopen("csp2022pj_decode.out","w",stdout);
ull k;
ull n,e,d;
cin>>k;
for(int i=1;i<=k;i++)
{
cin>>n>>e>>d;
ull m=n-e*d+2;//m
//求x^2-mx+n=0的解
ll delta=m*m-4*n;
if(delta<0)
{
cout<<"NO"<<endl;
continue;
}
ll sqt=sqrt(delta);
if(sqt*sqt!=delta)//如果√delta不是整数
{
cout<<"NO"<<endl;
continue;
}
ll up1=sqt+m,up2=m-sqt;
if(up1%2!=0||up2%2!=0||up1<=0||up2<=0)
{
cout<<"NO"<<endl;
continue;
}
up1/=2;up2/=2;
cout<<min(up1,up2)<<" "<<max(up1,up2)<<endl;
}
return 0;
}