Light OJ 1077 - How Many Points?
来源:互联网 发布:电脑游戏视频录制软件 编辑:程序博客网 时间:2024/04/29 19:01
思路:
对于一个数,求它的最大的约数就可以得到对这个数的最小分割,扩展至二维就是本题的要求的结果,求出最大公约数就可以得到二维的最小分割。
如图:
#include <stdio.h>#include <iostream>#include <string>#include <string.h>#include <algorithm>#include <stdlib.h>#include <math.h>#include <vector>#include <map>using namespace std;typedef long long ll;ll gcd(ll x,ll y){ return y?gcd(y, x%y):x;}int main(){ ll x1,x2,y1,y2; int t; scanf("%d",&t); for(int cas = 1;cas <= t;cas++){ scanf("%lld%lld%lld%lld",&x1,&y1,&x2,&y2); printf("Case %d: %lld\n",cas,gcd(abs(x1-x2), abs(y1-y2))+1); } return 0 ;}
0 0
- light oj 1077 how many points?
- Light OJ 1077 - How Many Points?
- light oj 1140 - How Many Zeroes?
- LightOJ 1077 How Many Points?
- Light oj 1140 - How Many Zeroes?(数位dp)
- Light OJ 1140 How Many Zeroes? (数位DP)
- Light oj 1140 - How Many Zeroes? 数位dp
- lightoj 1077 - How Many Points? 最大公约数
- LightOJ 1077 How Many Points? (变种gcd)
- How Many Points? gcd
- How Many Points of Intersection?
- How Many Points of Intersection?
- How Many Points of Intersection?
- How Many Points of Intersection?
- LightOJ 1077 - How Many Points? (线段整数点个数)
- Light OJ 1266 - Points in Rectangle
- UVa 10790 How Many Points of Intersection?
- uva 10790 How Many Points of Intersection?
- zoj1444 Final Standings解题报告
- mac下使用versions无法上传.a .so文件解决办法
- 读书笔记-APUE第三版-(8)进程控制
- 分类---LibSVM
- Eclipse基础--使用links方式安装Eclipse插件
- Light OJ 1077 - How Many Points?
- MySQL Server远程用户访问方法
- C++中的头文件和源文件:如何写头文件
- Fragment生命周期
- 我对委托的理解2
- SQL Server 和 MySql 的区别
- RTMP中FLV流到标准h264、aac的转换
- lua之card 游戏
- 比较好的题目“典型的最小生成树”