hdu 5974 A Simple Math Problem
来源:互联网 发布:g92内螺纹编程实例解释 编辑:程序博客网 时间:2024/05/29 17:56
Given two positive integers a and b,find suitable X and Y to meet the conditions: X+Y=a Least Common Multiple (X, Y) =b
6 8798 10780
No Solution308 490
ac代码:
#include <iostream>#include <cstdio>#include <cstring>#include <cmath>using namespace std;int gcd(int a,int b){ return b?gcd(b,a%b):a;}int main(){ int x,y; while(cin>>x>>y) { int d=gcd(x,y); int k=x/d; int h=y/d; int flag=0; int l=k*k-4*h; double p; if(l<0||(sqrt(l)*sqrt(l)!=l)) flag=1; else { p=(k+sqrt(l))/2.0; if(int(p)!=p) flag=1; } if(flag==1) cout<<"No Solution"<<endl; else if((int)p<=(k-(int)p)) cout<<(int)p*d<<" "<<(k-(int)p)*d<<endl; else cout<<(k-(int)p)*d<<" "<<(int)p*d<<endl; } return 0;}
阅读全文
0 0
- hdu 5974 A Simple Math Problem
- hdu 5974 A Simple Math Problem
- hdu 5974 A Simple Math Problem
- HDU 5974 A Simple Math Problem(数论)
- hdu 5974 A Simple Math Problem
- hdu 5974 A Simple Math Problem
- hdu 5974 A Simple Math Problem
- HDU 5974 A Simple Math Problem 数学
- hdu 5974 A Simple Math Problem
- HDU 5974 A Simple Math Problem
- hdu 5974 A Simple Math Problem
- hdu 5974 A Simple Math Problem
- HDU 5974 A Simple Math Problem
- HDU-5974-A Simple Math Problem
- [HDU](5974)A Simple Math Problem ---数论
- hdu A Simple Math Problem
- A Simple Math Problem (HDU
- A Simple Math Problem HDU
- 守护进程
- 欢迎使用CSDN-markdown编辑器
- MySQL基本操作
- 微信小程序开发前的准备工作
- 经典排序算法——堆排序(基本算法之一)
- hdu 5974 A Simple Math Problem
- Python的并发编程
- vue知识浅析
- JavaWeb学习总结(一)——JavaWeb开发入门
- mob第三方登录
- linux消息队列
- 在开发SSH项目时,使用Log4j配置监听日志,出现的异常处理方法
- Error (169008): Can't turn on open-drain option for differential I/O pin
- 广播接受者