主题:[讨论]菜鸟 求一ACM题算法 恳请高手不吝赐教 感激不尽
The blocks in the city of Fishburg are of square form. N avenues running south to north and M streets running east to west bound them. A helicopter took off in the most southwestern crossroads and flew along the straight line to the most northeastern crossroads. How many blocks did it fly above?
Note. A block is a square of minimum area (without its borders).
Input
The input contains N and M separated by one or more spaces.
1 < N, M < 32000
Output
The number of blocks the helicopter flew above.
Samples
input
4 3
output
4
input
3 3
output
2
正方形方格 从左下角引一条直线到右上角 输出 直线经过的 方格的数量
Note. A block is a square of minimum area (without its borders).
Input
The input contains N and M separated by one or more spaces.
1 < N, M < 32000
Output
The number of blocks the helicopter flew above.
Samples
input
4 3
output
4
input
3 3
output
2
正方形方格 从左下角引一条直线到右上角 输出 直线经过的 方格的数量