logic - A java practice problem -


I have come to javabat () in this problem:

We want to create a line The target's inches of bricks are tall, we have many small bricks (1 inch each) and big bricks (every 5 inches). Return to if possible to choose from the given bricks and make a goal. It looks like it is a little hard and can be done without any end.

The Macbricks (3, 1, 8) → True
MacBooks (3, 1, 9) → False
Macbriks (3, 2, 10) → True

I came up with this solution:

  Public Boolean Mechanics (int small, int big, int target) {If (target> small + big * 5) return false; And if (target% 5 == 0) return target / 5 & lt; = Big; The second goal goal is 5% & lt; = Small; }  

passed this exam but I got a counter-example: makeBricks (10, 0, 10) -> true. I will return my argument incorrectly. How should I fix my argument? Or is there a better way to do this?

I think you can take your second test, I'll try it:

< Pre> public boolean mechanics (int small, int big, int target) {if (target> small + big * 5) return false; The second goal goal is 5% & lt; = Small; }

Comments

Popular posts from this blog

c++ - Linux and clipboard -

What is expire header and how to achive them in ASP.NET and PHP? -

sql server - How can I determine which of my SQL 2005 statistics are unused? -