Description
费马大定理:当n>2时,不定方程an+bn=cn没有整数解。比如a3+b3=c3没有正整数解。我们来给他开个玩笑:把方程改成a3+b3=c3,这样就有解了,比如a=4, b=9, c=79时43+93=793。
输入两个整数x, y, 求满足x<=a,b,c<=y的整数解的个数。
Input
输入最多包含10组数据。每组数据包含两个整数x, y(1<=x,y<=108)。
Output
对于每组数据,输出解的个数。
Sample Input
Sample Output
HINT
水题啊
Source
#include<iostream>
using namespace std;
int main()
{
int x,y;
long long xxx,yyy,ccc;
int Case=0;
while(cin>>x>>y)
{
int i;
int j;
int count1=0;
for(i=x; i<=y; i++)
{
xxx=i*i;
if(xxx<i)
break;
xxx=xxx*i;
for(j=x; j<=y; ++j)
{
yyy=j*j;
if(yyy<j)
break;
yyy=yyy*j;
ccc=xxx+yyy;
if(ccc/10>y) || ccc<xxx || ccc<yyy)
break;
else
{
if(3==ccc%10)
++count1;
}
}
}
++Case;
cout<<"Case "<<Case<<": "<<count1<<endl;
}
return 0;
}