蓝桥杯-方程整数解

方程整数解

方程: a^2 + b^2 + c^2 = 1000
这个方程有整数解吗?有:a,b,c=6,8,30 就是一组解。
你能算出另一组合适的解吗?

请填写该解中最小的数字。

注意:你提交的应该是一个整数,不要填写任何多余的内容或说明性文字。

AC代码

#include <iostream>
using namespace std;
typedef long long ll;
ll n,p=0x7f7f7f7f7f;
ll quickmul(ll x,ll m) {ll re=0;while(m) {if(m&1) {re=(re+x)%p;}x=(x+x)%p;m>>=1;}return re;}ll pow_m(ll a,ll n,ll p) {ll ret=1;ll temp=a%p;while (n) {if (n&1) ret=quickmul(ret,temp)%p;temp=quickmul(temp,temp)%p;n>>=1;}return ret;}inline int read() {int X=0;bool flag=1;char ch=getchar();while(ch<'0'||ch>'9') {if(ch=='-') flag=0;ch=getchar();}while(ch>='0'&&ch<='9') {X=(X<<1)+(X<<3)+ch-'0';ch=getchar();}if(flag) return X;return ~(X-1);}
int main() {
for(int i=1;i<=34;i++)
for(int j=1;j<=34;j++)
for(int t=1;t<=34;t++)
{
	if(i*i+j*j+t*t==1000)
	cout<<i<<" "<<j<<" "<<t<<endl;
}
得出来答案是10}
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

zengyz-wh

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值