标签:
马与瓦
总共同拥有 100 匹马
总共驮有 100 块瓦(古代的瓦,非常大,非常重)
每匹大马每次能驮 3 块瓦
每匹小马每次能驮 2 块瓦
小马驹每次 2个马驹驮 1块瓦
求各种马的数目
提示:可能是多解的。要列出全部的解。
public class Test {
public static void main(String[] args){
int x ;
int y ;
int z ;
for(x=0;x<=100;x++){
for(y=0;y<=100-x;y++){
z=100-x-y;
if(x*3+y*2+(100-x-y)*0.5==100){
System.out.println(x+","+y+","+z);
}
}
}
}
}版权声明:本文博客原创文章。博客,未经同意,不得转载。
标签:
原文地址:http://www.cnblogs.com/lcchuguo/p/4662605.html