HDU1713 gcd
来源:互联网 发布:英伟达游戏优化软件 编辑:程序博客网 时间:2024/06/06 21:39
GCD乱搞。。。
#include <iostream>#include <cstdio>#include <cstdlib>#include <cmath>#include <cstring>#include <string>#include <algorithm>#include <vector>#include <set>#include <map>#include <queue>#include <stack>using namespace std;#define ll __int64ll gcd(ll n,ll m){ if(n==0) return m; return gcd(m%n,n);}int main(){ int T; ll t1,q1,t2,q2,t; scanf("%d",&T); while(T--) { scanf("%I64d/%I64d %I64d/%I64d",&t1,&q1,&t2,&q2); while(t=gcd(t1,q1),t!=1) { t1/=t; q1/=t; } while(t=gcd(t2,q2),t!=1) { t2/=t; q2/=t; } ll zi=t1*t2/gcd(t1,t2); ll mu=gcd(q1,q2); ll temp=gcd(zi,mu); zi/=temp; mu/=temp; if(mu==1) printf("%I64d\n",zi); else printf("%I64d/%I64d\n",zi,mu); } return 520;}
0 0
- HDU1713 gcd
- hdu1713
- hdu1713
- hdu1713 相遇周期
- HDU1713 相遇周期
- HDU1713 最小周期
- hdu1713 相遇周期
- hdu1713-相遇周期
- hdu1713相遇周期
- HDU1713 相遇周期(数学)
- HDU1713--相遇周期 HDU(110)
- gcd
- GCD
- GCD
- GCD
- GCD
- GCD
- GCD
- 判断字符串为空以及转换空字符串
- Android之UI自适应解决方案
- Java AWT基础及布局管理
- oracle11g突然连不上了,ora-12514 和 ora-27101
- union中的order by的应用
- HDU1713 gcd
- 无线通信系统DIY
- 职场新人成长宝典
- [c.y.j]转载 linux 硬盘挂载
- 单例设计模式与静态类,静态方法的联系
- JAVA IP地址转成长整型方法
- 使用CocoaPods(二)删除已经配置的类库和移除CocoaPods
- 最长回文子串
- UVA - 10014 Simple calculations