Romantic

              Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)
              Total Submission(s): 7187    Accepted Submission(s):
3027

Problem Description
The Sky is Sprite.
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
The input contains multiple test cases.
Each case
two nonnegative integer a,b (0<a, b<=2^31)
 
Output
output nonnegative integer X and integer Y, if there
are more answers than the X smaller one will be choosed. If no answer put
"sorry" instead.
 
Sample Input
77 51
10 44
34 79
 
Sample Output
2 -3
sorry
7 -3
 
Author
yifenfei
 
Source
 
Recommend
lcy
 

Statistic | Submit | Discuss | Note

Home | Top Hangzhou
Dianzi University Online Judge 3.0
Copyright © 2005-2017 HDU ACM Team. All Rights Reserved.
Designer & Developer: Wang
Rongtao
 LinLe GaoJie GanLu
Total
0.000000(s) query 1, Server time : 2017-08-09 15:18:23, Gzip enabled
Administration

思路:

裸的拓展欧几里得求乘法逆元   好像不开long long会wa掉

代码:

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
long long t,a,b,x,y,gcd;
long long exgcd(long long a,long long b,long long &x,long long &y)
{
    )
    {
        x=,y=;
        return a;
    }
    long long r=exgcd(b,a%b,x,y),tmp;
    tmp=x,x=y,y=tmp-a/b*y;
    return r;
}
int main()
{
    while(~scanf("%lld%lld",&a,&b))
    {
        gcd=exgcd(a,b,x,y);x%=b;
        ) printf("sorry\n");
        ) x+=b/gcd;   y=(-a*x)/b; printf("%lld ",x);printf("%lld\n",y);}
    }
    ;
}

Problem 2669的更多相关文章

  1. bzoj 2669 状压DP

    因为最多有8个'X',所以我们可以用w[i][s]来表示现在我们填了前i个数,填的X的为S,因为每次新加进来的数都不影响前面的最小值,所以我们可以随便添加,这样就有了剩下所有位置的方案,每次都这样转移 ...

  2. hdu 2669 Romantic

    Romantic Time Limit:1000MS     Memory Limit:32768KB     64bit IO Format:%I64d & %I64u Submit Sta ...

  3. ●BZOJ 2669 [cqoi2012]局部极小值

    题链: http://www.lydsy.com/JudgeOnline/problem.php?id=2669 题解: 容斥,DP,DFS 先看看 dp 部分:首先呢,X的个数不会超过 8个.个数很 ...

  4. BZOJ 2669 CQOI2012 局部极小值 状压dp+容斥原理

    题目链接:http://www.lydsy.com/JudgeOnline/problem.php?id=2669 题意概述:实际上原题意很简洁了我就不写了吧.... 二话不说先观察一下性质,首先棋盘 ...

  5. HDU 2669 Romantic(扩展欧几里德)

    题目链接:pid=2669">http://acm.hdu.edu.cn/showproblem.php?pid=2669 Problem Description The Sky is ...

  6. BZOJ 2669 Luogu P3160 [CQOI2012]局部极小值 (容斥原理、DP)

    题目链接 (bzoj) https://www.lydsy.com/JudgeOnline/problem.php?id=2669 (luogu) https://www.luogu.org/prob ...

  7. 1199 Problem B: 大小关系

    求有限集传递闭包的 Floyd Warshall 算法(矩阵实现) 其实就三重循环.zzuoj 1199 题 链接 http://acm.zzu.edu.cn:8000/problem.php?id= ...

  8. No-args constructor for class X does not exist. Register an InstanceCreator with Gson for this type to fix this problem.

    Gson解析JSON字符串时出现了下面的错误: No-args constructor for class X does not exist. Register an InstanceCreator ...

  9. C - NP-Hard Problem(二分图判定-染色法)

    C - NP-Hard Problem Crawling in process... Crawling failed Time Limit:2000MS     Memory Limit:262144 ...

随机推荐

  1. python 操作数据库时遇到的错误

       pymysql.err.ProgrammingError: (1064, "You have an error in your SQL syntax; ch    之前的写法是从文件里 ...

  2. web api 二

    接着上一回说,上回说到,web api有几种访问方式,具体有几种,我还真没去研究过,但是这里打算从get.post.put.delete四种请求方式分别谈谈基础类型(包括int/string/date ...

  3. Docker学习系列(二):Docker三十分钟快速入门(上)

    一.背景 ​ 最近,Docker技术真是一片火热,它的出现也弥补了虚拟机资源消耗过高的问题,直接让虚拟化技术有了质的飞跃.那么本文我们来聊一聊Docker,和大家一起认识Docker,简单入门Dock ...

  4. layer父页获取弹出层输入框里面的值

    主要是因为修改功能,原来页面填写数据如图 改为 其中点击填写明细弹出框 填写完毕后点击确认返回,同事这里因为她是存的多表,所以点击确认就直接保存数据了,改的这个功能原本保存是整体保存,我就不想改原来的 ...

  5. ASP.NET文件操作

    在开发Web程序时,不但有存储在数据库中和XML文件中的数据形式需要处理,而且还有很多诸如文本.Word文档和图片等格式的文件数据需要处理.尤其是在一些信息管理系统中,文档的处理流程贯穿了整个系统的运 ...

  6. 在中间层 .NET 应用程序中通过授权管理器使用基于角色的安全

    基于角色的安全是从 Windows NT 的第一个版本开始在 Windows 平台上发展而来的.使用角色,操作系统可以通过检查称为 BUILTIN\Administrators 的组的安全上下文做出一 ...

  7. NVIDIA各个领域芯片现阶段的性能和适应范围

    NVIDIA作为老牌显卡厂商,在AI领域深耕多年.功夫不负有心人,一朝AI火,NVIDIA大爆发,NVIDIA每年送给科研院所和高校的大量显卡,大力推广Physix和CUDA,终于钓了产业的大鱼. 由 ...

  8. 创建一个TCP服务器端通信程序的步骤

    创建一个TCP服务器端通信程序的步骤: 1). 创建一个ServerSocket 2). 从ServerSocket接受客户连接请求 3). 创建一个服务线程处理新的连接 4). 在服务线程中,从so ...

  9. vue(数据改变,DOM不渲染问题)

    1.组件内部,属性值地址空间内引用地址改变,DOM不能渲染. 问题举例:this.items = [[],[],[],[]] 1.在items 中,修改任意一项数组中的值,DOM是不会更新的,2.解决 ...

  10. arx 移动界面到一点

    AcDbViewTableRecord view; AcGePoint3d max = acdbHostApplicationServices()->workingDatabase()-> ...