HDU 2504 又见GCD
2010-09-27 12:30
260 查看
题目:http://acm.hdu.edu.cn/showproblem.php?pid=2504
代码
代码
#include <iostream> using namespace std; int gcd(int a,int b) { while(a%b) { int r=a%b; a=b; b=r; } return b; } int main() { int n,a,b,c,i,j; cin>>n; for (i=0;i<n;i++) { cin>>a>>b; c=2*b; while(gcd(a,c)!=b) { c+=b; } cout<<c<<endl; } return 0; }
相关文章推荐
- hdu-2504-又见GCD
- HDU 2504 又见GCD(最大公约数与最小公倍数变形题)
- hdu 2504 又见gcd
- HDU 2504 又见GCD(gcd)
- C - 又见GCD HDU - 2504
- HDU2504又见GCD
- HDU 2504 又见GCD
- HDOJ(HDU) 2504 又见GCD(利用最大公约数反推)
- hdu 2504 又见Gcd
- GCD & 拓展GCD 入门——HDU - 2504,UVA - 10673
- HDU 2504 又见GCD
- HDOJ(HDU) 2504 又见GCD(利用最大公约数反推)
- hdu 2504 又见GCD
- hdu2504又见GCD
- HDU 2504 又见GCD
- HDU-2504 又见GCD
- HDU-2504-又见GCD
- hdu 2504 又见GCD
- hdu 2504 又见GCD
- 【hdu 2504】又见GCD(数学相关)