Last Defence - UVA7045
2015-10-10 15:24
351 查看
https://icpcarchive.ecs.baylor.edu/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&problem=5057
不知道为什么是这个规律
不知道为什么是这个规律
#include <iostream> using namespace std; long long a, b, ans; int nCase, cCase; long long calc(long long a, long long b) { long long ret = 0; while (b) { long long t = b; ret += a / b; b = a % b; a = t; } return ret + 1; } int main() { //ios::sync_with_stdio(false); cin >> nCase; while (nCase--) { cin >> a >> b; if (a == 0 && b == 0) { ans = 1; } else if (a == 0 || b == 0) { ans = 2; } else { ans = calc(a, b); } cout << "Case #" << ++cCase << ": " << ans << endl; } return 0; }
相关文章推荐
- extjs中store的reload事件异步问题解决
- json文件解析,包含孙节点
- 最全的CSS浏览器兼容问题
- 漂亮的CSS3圆角按钮组合DEMO演示
- js获取高度
- MVC 调试页面路径变成 Views/Controller/Action.cshtml问题
- jQuery中的.height()、.innerHeight()和.outerHeight()
- javaScript常用正则表达式
- javaScript读取页面表格中每个单元到EXCEL中
- 纯css实现高尔夫小球动画案例分析
- 自定义Flex组件
- css中float浮动原理及使用方法
- React组件定义验证属性值和默认值的配置
- 巧用css美化select下拉列表 更换下拉箭头
- 高效CSS开发核心要点摘录
- JSON.parse()方法
- 根据select选项的值,改变css
- jQuery 获取表单元素中值的方法
- html a标签
- JavaScript正则表达式