蓝桥杯-方程整数解

方程整数解

方程: 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}

猜你喜欢

转载自blog.csdn.net/qq_34832548/article/details/115446090