2015年蓝桥杯省赛A组c++第1题

时间:2023-03-08 16:56:19
/*
方程: a^2 + b^2 + c^2 = 1000
这个方程有整数解吗?有:a,b,c=6,8,30 就是一组解。
你能算出另一组合适的解吗?
请填写该解中最小的数字。
注意:你提交的应该是一个整数,不要填写任何多余的内容或说明性文字。
*/ #include<iostream>
#include<algorithm>
#include<cmath>
using namespace std;
static int solution=;
int main()
{
for(int a=;a<sqrt();a++)
for(int b=;b<sqrt();b++)
for(int c=;c<sqrt();c++)
if(pow(a,)+pow(b,)+pow(c,)==){
solution++;
cout<<a<<","<<b<<","<<c<<","<<endl;
}
cout<<solution<<endl;
return ;
}

tz@COI HZAU

2018/3/14