report VI VI EN
Register | Login
  • HOME
  • PROBLEMSET
  • ROADMAP
  • COMPETITION
  • TOPIC
  • RANKING
  • GUIDE
  • MASHUP
  • ABOUT
  • CONTACT
  • Problem
  • Submit
  • Results
Rectangle cutting - MarisaOJ: Marisa Online Judge

Rectangle cutting

Time limit: 1000 ms
Memory limit: 256 MB
Given an $a \times b$ rectangle, your task is to cut it into squares. On each move you can select a rectangle and cut it into two rectangles in such a way that all side lengths remain integers. What is the minimum possible number of moves? ### Input - The first line contains 2 integers $a, b$. ### Output - Print one integer, the minimum number of moves. ### Constraints - $1 \le a, b \le 500$. ### Example Input: ``` 3 5 ``` Output: ``` 3 ```
Introduction to dynamic programming
Hakurei Shrine
Buying tickets
Reading 2
Longest increasing subsequence
Jealousy
Maximum path 2
Fences painting
Hall
Knapsack 2
Longest common subsequence
Yet another build array problem
Rectangle cutting
Palindrome query
Marisa
Merging elements
Brewing potion 8
Topic
Dynamic Programming
Rating 1100
Solution (1) Solution