HDU2503(GCD&&LCM)
来源:互联网 发布:final java关键字 编辑:程序博客网 时间:2024/06/06 21:45
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2503
解题思路:
单纯的gcd和lcm,常识。
完整代码:
#include <functional>#include <algorithm>#include <iostream>#include <fstream>#include <sstream>#include <iomanip>#include <numeric>#include <cstring>#include <climits>#include <cassert>#include <complex>#include <cstdio>#include <string>#include <vector>#include <bitset>#include <queue>#include <stack>#include <cmath>#include <ctime>#include <list>#include <set>#include <map>using namespace std;#pragma comment(linker, "/STACK:102400000,102400000")typedef long long LL;typedef double DB;typedef unsigned uint;typedef unsigned long long uLL;/** Constant List .. **/ //{const int MOD = int(1e9)+7;const int INF = 0x3f3f3f3f;const LL INFF = 0x3f3f3f3f3f3f3f3fLL;const DB EPS = 1e-9;const DB OO = 1e20;const DB PI = acos(-1.0); //M_PI;int gcd(int a , int b){ return b == 0 ? a : gcd(b , a % b);}int lcm(int a , int b){ return a / gcd(a , b) * b;}int main(){ #ifdef DoubleQ freopen("in.txt","r",stdin); #endif std::ios::sync_with_stdio(false); std::cin.tie(0); int T; cin >> T; while(T--) { int a , b , c, d; cin >> a >> b >> c >> d; int t = lcm(b , d); int t1 = t / b * a + t / d * c; int k = gcd(t1 , t); cout << t1 / k << " " << t / k << endl; }}
0 0
- HDU2503(GCD&&LCM)
- hdu1099(gcd+lcm)
- HDU 4497 - GCD and LCM (质因式分解 GCD LCM)
- hdoj1108最小公倍数(GCD,LCM)
- GCD & LCM (数学基础)
- GCD 与 LCM(模板)
- gcd,lcm
- gcd & lcm
- LCM GCD
- GCD LCM
- lcm/gcd
- gcd & lcm
- GCD LCM
- 【GCD&LCM】
- gcd && lcm
- hdu2503
- HDU2503
- poj2492GCD & LCM Inverse(GCD&&LCM)(此题目前超时)
- 第三方应用如何调用google maps导航或显示某个区域的地图
- Android view getVisibility()的值
- nginx 安装 nginx_http_push_module
- 2、swift学习-创建基本的控件
- 最短路径算法—Dijkstra(迪杰斯特拉)算法的实现(C++)
- HDU2503(GCD&&LCM)
- [转载]数据结构二叉树深层理解
- 进程、线程和协程的理解
- FZU 2180 骑士 双向BFS
- 反渗透设备:反渗透设备工艺流程及用途具体阐述
- SQL Server日期时间函数
- 安装包压缩的追根溯源
- tomcat性能优化及其jvm内存分析
- canvas下雪效果