HDU 2669
来源:互联网 发布:数据库应用教程 编辑:程序博客网 时间:2024/06/05 17:00
扩展欧几里德算法
#include<stdio.h>#include<string.h>#include<math.h>#include<algorithm>#include <iostream>#include<queue>using namespace std;int x,y;int gcd(int m,int n){ if(m==0) { x=0; y=1; return n; } else { int tmp=gcd(n%m,m); int p1=y-n/m*x; int p2=x; x=p1; y=p2; return tmp; }}int main(){ int a,b; while(cin>>a>>b) { if(gcd(a,b)!=1) cout<<"sorry"<<endl; else { while(x<0) { x+=b; y-=a; } while(x-b>=0) { x-=b; y+=a; } cout<<x<<" "<<y<<endl; } } return 0;}
0 0
- hdu 2669
- HDU 2669
- HDU 2669
- HDU 2669
- (2669)HDU
- hdu 2669
- hdu 2669
- HDU 2669 Romantic
- hdu 2669 扩展欧几里得
- hdu 2669 C - Romantic
- hdu 2669 Romantic
- HDU 2669 扩展欧几里得
- Romantic(hdu 2669)
- hdu 2669(拓展欧几里得)
- 【HDU】 2669 Romantic
- HDU 2669 Romantic
- hdu 2669 Romantic
- HDU 2669 Romantic
- C++中的单例模式
- 腾讯面试题
- 《计算机程序的构造与解释》(总结)
- HDU 2159---FATE【二维完全背包】
- Hadoop集群(第1期)_CentOS安装配置
- HDU 2669
- 一淘搜索之网页抓取系统分析与实现(4)- 实现&总结
- A - 简单字符串排序
- USACO--1.2 Transformations
- hdu 4862 KM算法 最小K路径覆盖的模型
- POJ 1141 Brackets Sequence (区间DP)
- Hibernate核心接口
- 【POMELO】深入浅出node.js游戏服务器开发
- 字符编码笔记:ASCII,Unicode和UTF-8