タイトルの説明:
アルゴリズムのアイデア:
- 等式変換:元の式はd e f *(b c + c a + a b)= a b c(e f + f d + d * e)です。元の式を使用する場合は、浮動小数点を実行する必要があります。 -点演算、浮動小数点数は演算が容易ではないため、整数演算は変形によって実行されます
- 間隔を分割する:条件に従って間隔を分割します
すべてのコード:
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
int a,b,c,d,e,f,s,cnt=0;
int main(){
scanf("%d",&s);
for(a=1;a<=(s-3)/3;a++)
for(b=a+1;b<=(s-a-1)/2;b++)
for(d=a+1;d<=(s-3)/3;d++)
for(e=d+1;e<=(s-d-1)/2;e++){
c = s - a - b;
f = s - d - e;
int tmp0 = d*e*f*(b*c+c*a+a*b);
int tmp1 = a*b*c*(e*f+f*d+d*e);
if(tmp0==tmp1){
cnt++;
printf("%d:(%d,%d,%d) ",cnt,a,b,c);
printf("(%d,%d,%d)\n",d,e,f);
}
}
if(cnt==0) printf("无解");
return 0;
}