???题目7 : Bounce
来源:互联网 发布:Linux查看硬件信息 编辑:程序博客网 时间:2024/06/08 13:05
题目7 : Bounce
- 样例输入
2 22 33 43 54 54 64 75 65 79 15
- 样例输出
235578791139
描述
For Argo, it is very interesting watching a circle bouncing in a rectangle.
As shown in the figure below, the rectangle is divided into N×M grids, and the circle fits exactly one grid.
The bouncing rule is simple:
1. The circle always starts from the left upper corner and moves towards lower right.
2. If the circle touches any edge of the rectangle, it will bounce.
3. If the circle reaches any corner of the rectangle after starting, it will stop there.
Argo wants to know how many grids the circle will go through only once until it first reaches another corner. Can you help him?
输入
The input consists of multiple test cases. (Up to 105)
For each test case:
One line contains two integers N and M, indicating the number of rows and columns of the rectangle. (2 ≤ N, M ≤ 109)
输出
For each test case, output one line containing one integer, the number of grids that the circle will go through exactly once until it stops (the starting grid and the ending grid also count).
比赛已经结束,去题库提交。
- ???题目7 : Bounce
- BZOJ 题目2002: [Hnoi2010]Bounce 弹飞绵羊(link cut tree)
- bounce buffer
- bounce buffer
- 论 FTP bounce 攻击
- Bounce-Bon Jovi
- Broadcast Email Bounce Codes
- Email Bounce Code Explanations
- 《Windows程序设计》之BOUNCE
- DevBytes: Bounce Animations
- ode bounce例程整理
- 动态弹球Bounce
- Bounce Castle组件配置
- 6.4 bounce模块
- Codechef DECEMBER16 BOUNCE
- hihocoder 1584 Bounce
- hihododer #1584 : Bounce 【规律】
- 关闭postfix 退信 bounce
- 第4周项目3(3)- 单链表应用
- BOM,浏览器对象模型
- location对象
- history对象
- window对象的一些其他通用函数
- ???题目7 : Bounce
- 77777777777777
- 什么是.bat文件
- 使用JavaScript,点击按钮一个打开新的窗体
- JavaScript实现超时调用的功能
- myFocus制作网页焦点图 实现图片轮播效果
- Android页面跳转
- JavaScript实现显示在线时间的功能
- JavaScript实现显示时间,暂停时间,和取消显示时间