您的位置:首页 > 其它

双和数组探索算法

2017-03-14 00:25 169 查看
1.双和数组的概念:将一个偶数2S分解成六个互不相等的正整数a,b,c,d,e,f,这六个正整数满足三个条件:

1.a+b+c = d+e+f

2.1/a+1/b+1/c=1/d+1/e+1/f

3.a

public class test{
public static void main(String[] args){
test t = new test();
System.out.print("please input n:");
Scanner in = new Scanner(System.in);
int n = in.nextInt();
t.fun(n);
}
public void fun(int n){
int a,b,c,d,e,f;
for(a=1; a<=(n-3)/3; a++){
for(b=a+1; b<=(n-a-1)/2; b++){
for(d=a+1; d<=(n-3)/3; d++){
for(e=d+1; e<=(n-d-1)/2; e++){
c = n-a-b;
f = n-d-e;
if(d*e*f*(a*b+b*c+c*a) == a*b*c*(d*e+e*f+f*d)){
System.out.println("双和数组:" + "(" + a + "," + b + "," + c + "),(" + d + "," + e + "," + f + ")");
}
}
}
}
}
}
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: