HDU2669 Romantic
Description
The Birds is Fly in the Sky.
The Wind is Wonderful.
Blew Throw the Trees
Trees are Shaking, Leaves are Falling.
Lovers Walk passing, and so are You.
................................Write in English class by yifenfei
Girls are clever and bright. In HDU every girl like math. Every girl like to solve math problem!
Now tell you two nonnegative integer a and b. Find the
nonnegative integer X and integer Y to satisfy X*a + Y*b = 1. If no such
answer print "sorry" instead.
Input
Each case two nonnegative integer a,b (0<a, b<=2^31)
Output
than the X smaller one will be choosed. If no answer put "sorry"
instead.
Sample Input
10 44
34 79
Sample Output
sorry
7 -3
裸的扩展欧几里得
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<cmath>
using namespace std;
int exgcd(int a,int b,int &x,int &y){
if(b==){
x=;y=;
return a;
}
int res=exgcd(b,a%b,x,y);
int t=x;x=y;y=t-a/b*y;
return res;
}
int main(){
int a,b,x,y;
while(scanf("%d%d",&a,&b)!=EOF)
{
int g=exgcd(a,b,x,y);
if(%g)
printf("sorry\n");
else{
while(x<){x+=b;y-=a;}
printf("%d %d\n",x,y);
}
}
return ;
}
HDU2669 Romantic的更多相关文章
- HDU2669 Romantic 扩展欧几里德 对我来说有陷阱
这道题对我来说有陷阱虽说是赤果果的扩展欧几里德,看样子基本攻还是不够哈,基本功夫一定要好,准备每天上那种洗脑课时分 多看看数论书,弥补一下 自己 狗一样的基础, 这道题用到了一个性质: 对于不定整数 ...
- hdu 2669 Romantic
Romantic Time Limit:1000MS Memory Limit:32768KB 64bit IO Format:%I64d & %I64u Submit Sta ...
- hdu 2669 Romantic (乘法逆元)
Romantic Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Su ...
- 『摄影欣赏』16幅 Romantic 风格照片欣赏【组图】
今天,我们将继续分享人类情感的系列文章.爱是人类最重要的感觉,也可能是各种形式的艺术(电影,音乐,书,画等)最常表达的主题 .这里有40个最美丽的爱的照片,将激励和给你一个全新的视觉角度为这种情绪.我 ...
- HDU 4901 The Romantic Hero
The Romantic Hero Time Limit: 3000MS Memory Limit: 131072KB 64bit IO Format: %I64d & %I64u D ...
- HDU4901 The Romantic Hero 计数DP
2014多校4的1005 题目:http://acm.hdu.edu.cn/showproblem.php?pid=4901 The Romantic Hero Time Limit: 6000/30 ...
- HDU 4901 The Romantic Hero (计数DP)
The Romantic Hero 题目链接: http://acm.hust.edu.cn/vjudge/contest/121349#problem/E Description There is ...
- Romantic(裸扩展欧几里德)
Romantic Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Su ...
- HDU 4901 The Romantic Hero(二维dp)
题目大意:给你n个数字,然后分成两份,前边的一份里面的元素进行异或,后面的一份里面的元素进行与.分的时候依照给的先后数序取数,后面的里面的全部的元素的下标一定比前面的大.问你有多上种放元素的方法能够使 ...
随机推荐
- Python的循环正确的操作使用方法详解
要计算1+2+3,我们可以直接写表达式: >>> 1 + 2 + 3 6 要计算1+2+3+...+10,勉强也能写出来. 但是,要计算1+2+3+...+10000,直接写表达式就 ...
- openwrt(一):openwrt源码下载及编译环境搭建
声明:从网上各位大神的博客学习,整理后记录,非原创. 注:请用非root用户来下载源码 导航: 1. openwrt编译环境搭建 2. openwrt源码下载 3. feeds更新 1. openwr ...
- Codeforces146D 概率DP
Bag of mice The dragon and the princess are arguing about what to do on the New Year's Eve. The drag ...
- Snowflake Snow Snowflakes【Poj3349】
Description You may have heard that no two snowflakes are alike. Your task is to write a program to ...
- HDFS HA(High Availability)高可用性
HDFS HA(High Availability)高可用性 参考文献: 官方文档 全文翻译 Hadoop组件之-HDFS(HA实现细节) 这张图片的个人理解 由于NameNode在Hadoop1只有 ...
- Nginx 高级配置
nginx官方网站:http://nginx.org/ 1. Nginx连接后端的方式:反向代理(proxy_pass).直连fastcgi(fastcgi_pass) 例子: fastcgi_pa ...
- android onCreate的两个方法
override fun onCreate(savedInstanceState: Bundle?, persistentState: PersistableBundle?) { } override ...
- gulp相关
'use strict'; var gulp = require('gulp'), webserver = require('gulp-webserver'), //gulp服务器 connect = ...
- Jmeter获取Cookie并传递到下一个线程---跨线程后cookie找不到了
网上找了一堆文章没有一个是实际操作的,自己边试边查边摸索终于找到了一个全套的办法. 原创文章,转载请说明出处. 1.取得cookie 直接这样写就可以了${COOKIE_JSESSIONID},当然具 ...
- paramiko类Fabric主机管理
环境:Linux python3.5 要求:类 Fabric 主机管理程序开发:1. 运行程序列出主机组或者主机列表2. 选择指定主机或主机组3. 选择让主机或者主机组执行命令或者向其传输文件(上传/ ...