import java.util.Scanner;
public class blue {
public static void main(String[] args) {
// TODO Auto-generated method stub
Scanner gg=new Scanner(System.in);
while(gg.hasNext())//进行多组输入
{
int m=gg.nextInt();
int n=gg.nextInt();
int x,y,z,h=0;//h用来记录方案的次数
for(x=0;x<=100;x++)
{
for(y=0;y<=100;y++)
{
z=100-x-y;//总马数判断
if(mx+ny+z/2.0100)//判断总瓦数
h++;
}
}
if(h0)
System.out.println(“no solution”);
else
System.out.println(h);
}
}
}
此篇博客介绍了使用Java实现的一个算法,通过Scanner获取输入,解决马匹配种问题,判断能否找到满足马匹总数、瓦数限制的组合方案,并计数。核心是利用两层循环和条件判断来确定解决方案的数量。
1万+

被折叠的 条评论
为什么被折叠?



