9.22 4 Rectangle Cuts

/*
*
Xiao Ming has some rectangular materials, and he wants to cut some squares from these rectangular materials.
When he was faced with a piece of rectangular material, he always made a cut from the middle, cut out the largest square, left a piece of rectangle,
and then cut the remaining rectangular material until it was all squared. For example, for a piece of material with 5 and 3 on both sides (denoted as 5×3),
Xiaoming will cut out 4 squares of 3×3, 2×2, 1×1, and 1×1 in turn. Now Xiaoming has a rectangular material with the lengths of 2019 and 324 on both sides.
How many squares will Xiao Ming cut out in the end?

*/
public class Demo2 { public static void main(String[] args) { int a=2019; int b=324; int i=0; for(i=0;i<=50;i++){ if(a>b){ a=a-b; }else if(b>a){ b=b-a; }else if(a==b){ i++; break; } } System.out.println(i); } }
















Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325292335&siteId=291194637