UVALive 7045 Last Defence(找规律)
来源:互联网 发布:新手怎么做淘宝客 编辑:程序博客网 时间:2024/05/17 03:36
思路:找一下规律,就是一个类似辗转相除法的东西...
#include <stdio.h>#include <string.h>#include <iostream>#include <algorithm>#include <vector>#include <queue>#include <set>#include <map>#include <string>#include <math.h>#include <stdlib.h>#include <time.h>using namespace std;typedef long long ll;ll a, b;ll get(ll A, ll B){if(B==0) return 1;ll t = A%B, ans=0;ans = A/B + get(B, t);return ans;}int main(){ //freopen("in.txt","r",stdin); //freopen("out.txt","w",stdout);int ca=1,tt;scanf("%d", &tt);while(ca<=tt){scanf("%lld%lld", &a, &b);if(b>a) swap(a, b);if(a!=0&&b==0) printf("Case #%d: %lld\n", ca++, 2);else printf("Case #%d: %lld\n", ca++, get(a, b));} return 0;}
0 0
- UVALive 7045 Last Defence(找规律)
- UVALive - 7045 Last Defence (更相减损术)
- 文章标题 UVALive 7045:Last Defence(辗转相除思想)
- UVALive 6847 Zeroes(找规律)
- 【找规律】UVALive
- Last Defence
- UVALive 6270 Edge Case(找规律,大数相加)
- 【UVALive】2037 - Digital Rivers(找规律,暴力)
- UVAlive-6577 Binary Tree(递推+找规律)
- UVALive - 6832 Bit String Reordering (找规律)
- Beehive UVALive - 7528 (找规律+数学思维)
- UVALIVE 3786 Fairies' Defence
- UVALive 6345 The Glittering Caves of Aglarond (找规律求最多)
- UVALive 5760 Alice and Bob(博弈+记忆化dp or 找规律)
- UVALive7045 Last Defence(GCD思想)
- HDOJ1021(找规律)
- POJ1740(找规律)
- hdu (找规律)
- CodeForces 362B Petya and Staircases
- Exam 1 Character Recognition - Works Application 16
- Android 垂直seekbar
- 用DateUtil.js将时间路转为正确的日期格式
- 实习入职第十二天:Android中Bitmap,byte[],Drawable,InputStream相互转化工具类
- UVALive 7045 Last Defence(找规律)
- sdut 3100
- Linux命令学习之ls命令
- 关于基类和派生类的动态绑定问题
- 派生类的构造和析构函数
- Canvas之画布操作
- swift学习之路(七)可选
- linux 代码编程风格
- html 获取图片的宽和高