专栏文章
数学游戏
P8255题解参与者 1已保存评论 0
文章操作
快速查看文章及其快照的属性,并进行相关操作。
- 当前评论
- 0 条
- 当前快照
- 1 份
- 快照标识符
- @minm4zqs
- 此快照首次捕获于
- 2025/12/02 04:39 3 个月前
- 此快照最后确认于
- 2025/12/02 04:39 3 个月前
计算过程
有
不妨令
原式
注意到
又注意到
因为
所以
所以
当 , 不为完全平方数时不成立
不妨令
原式
注意到
又注意到
因为
所以
所以
当 , 不为完全平方数时不成立
Code
CPP#include<iostream>
#include<algorithm>
#define int long long
using namespace std;
int t,x,z;
signed main()
{
scanf("%lld",&t);
while(t--)
{
scanf("%lld%lld",&x,&z);
if(z % x != 0)cout << -1;
else
{
int t = z / x;
int a = sqrt(__gcd(t,x * x));
if(a * a != __gcd(t,x * x))
{
puts("-1");
continue;
}
cout << t/a;
}
}
return 0;
}
相关推荐
评论
共 0 条评论,欢迎与作者交流。
正在加载评论...