HDU 2669 Romantic(扩展欧几里德)
来源:互联网 发布:mac命令行安装mysql 编辑:程序博客网 时间:2024/06/06 04:31
题意:Now tell you two nonnegative integer a and b. Find the nonnegative integer X and integer Y to satisfy X*a + Y*b = 1.
而且要满足X是通解中最小的。
注意X可以取0就可以了
//31MS 1808K 761 B G++#include<cstdio>#include<cstring>#include<iostream>#include<algorithm>using namespace std;typedef long long ll;ll e_gcd(ll a,ll b,ll &x,ll&y){ ll ans; if(b==0) { ans=a; x=1,y=0; } else { ans=e_gcd(b,a%b,y,x); y-=(a/b)*x; } return ans;}int main(){ ll a,b,x,y; while(~scanf("%I64d%I64d",&a,&b)) { ll gcd=e_gcd(a,b,x,y); if(gcd!=1) puts("sorry"); else { while(x<0) { x+=b; y-=a; } printf("%I64d %I64d\n",x,y); } } return 0;}
0 0
- HDU 2669 Romantic(扩展欧几里德)
- HDU 2669 Romantic(扩展欧几里德)
- HDU 2669 Romantic(扩展欧几里德)
- hdu 2669 Romantic 扩展欧几里德
- HDU 2669 Romantic(扩展欧几里德)
- HDU 2669----Romantic(扩展欧几里德求乘法逆元)
- HDU 2669Romantic(扩展欧几里德裸题)
- HDOJ 2669 Romantic (扩展欧几里德)
- Romantic (扩展欧几里德算法)
- hdu - 2669 - Romantic(扩展欧几里得)
- 【HDU】2669 - Romantic(扩展欧几里得)
- HDU 2669:Romantic(扩展欧几里得)
- 【hdu 2669】Romantic(扩展欧几里得)
- hdu 2669 Romantic (扩展欧几里得)
- HDU 2669 Romantic 扩展欧几里得
- HDU 2669 Romantic(扩展欧几里得)
- HDU 2669 Romantic (扩展欧几里得)
- hdu 2669 Romantic 扩展欧几里得
- 我的android作品,9.7寸平板界面截图
- 复习前段时间的(查漏补缺)
- IOS 开发进阶--多线程和网络--多线程的基础知识的了解
- Webserver/servlet容器选型
- UI设计师网址导航
- HDU 2669 Romantic(扩展欧几里德)
- Eclipse错误: 找不到或无法加载主类或项目无法编译10种解决大法!
- 【BZOJ 1875】 [SDOI2009]HH去散步
- hdu3555经典的数位dp
- c++中易混淆的概念
- 找最大值和最小值
- Android开发最佳实践建议
- Struts2数据传输的背后机制:ValueStack(值栈)
- 2015年3月13日