Problem 2669
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. 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
|
|||
|
思路:
裸的拓展欧几里得求乘法逆元 好像不开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的更多相关文章
- bzoj 2669 状压DP
因为最多有8个'X',所以我们可以用w[i][s]来表示现在我们填了前i个数,填的X的为S,因为每次新加进来的数都不影响前面的最小值,所以我们可以随便添加,这样就有了剩下所有位置的方案,每次都这样转移 ...
- hdu 2669 Romantic
Romantic Time Limit:1000MS Memory Limit:32768KB 64bit IO Format:%I64d & %I64u Submit Sta ...
- ●BZOJ 2669 [cqoi2012]局部极小值
题链: http://www.lydsy.com/JudgeOnline/problem.php?id=2669 题解: 容斥,DP,DFS 先看看 dp 部分:首先呢,X的个数不会超过 8个.个数很 ...
- BZOJ 2669 CQOI2012 局部极小值 状压dp+容斥原理
题目链接:http://www.lydsy.com/JudgeOnline/problem.php?id=2669 题意概述:实际上原题意很简洁了我就不写了吧.... 二话不说先观察一下性质,首先棋盘 ...
- HDU 2669 Romantic(扩展欧几里德)
题目链接:pid=2669">http://acm.hdu.edu.cn/showproblem.php?pid=2669 Problem Description The Sky is ...
- BZOJ 2669 Luogu P3160 [CQOI2012]局部极小值 (容斥原理、DP)
题目链接 (bzoj) https://www.lydsy.com/JudgeOnline/problem.php?id=2669 (luogu) https://www.luogu.org/prob ...
- 1199 Problem B: 大小关系
求有限集传递闭包的 Floyd Warshall 算法(矩阵实现) 其实就三重循环.zzuoj 1199 题 链接 http://acm.zzu.edu.cn:8000/problem.php?id= ...
- 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 ...
- C - NP-Hard Problem(二分图判定-染色法)
C - NP-Hard Problem Crawling in process... Crawling failed Time Limit:2000MS Memory Limit:262144 ...
随机推荐
- spring 嵌套事务问题
嵌套事物总结 事物成功总结 1.内外都无try Catch的时候,外部异常,全部回滚. 2.内外都无try Catch的时候,内部异常,全部回滚. 3.外部有try Catch时候,内部异常,全部回滚 ...
- [转]C语言文件操作函数大全(超详细)
fopen(打开文件)相关函数 open,fclose表头文件 #include<stdio.h>定义函数 FILE * fopen(const char * path,const cha ...
- [BZOJ3224/Tyvj1728]普通平衡树
本篇博客有详细题解,浅谈算法--splay
- Storm概念学习系列之storm流程图
把stream当做一列火车, tuple当做车厢,spout当做始发站,bolt当做是中间站点!!! 见 Storm概念学习系列之Spout数据源 Storm概念学习系列之Topology拓扑 Sto ...
- [译]curl_multi_info_read
curl_multi_info_read - read multi stack informationals读取multi stack中的信息 SYNOPSIS#include <curl/cu ...
- Java 8 (5) Stream 流 - 收集数据
在前面已经使用过collect终端操作了,主要是用来把Stream中的所有元素结合成一个List,在本章中,你会发现collect是一个归约操作,就像reduce一样可以接受各种做法作为参数,将流中的 ...
- Android RecyclerView 滑动时图片加载的优化
RecyclerView 滑动时的优化处理 在滑动时停止加载图片,在滑动停止时开始加载图片,这里用了Glide.pause 和Glide.resume.这里为了避免重复设置增加开销,设置了一个标志变量 ...
- Linux学习笔记之Linux命令
1. blkid 查看当前系统中所有已挂载文件系统的类型
- java树型结构的数据展现设计
在做一个需求管理的页面时,需求的展现是不限层级树型结构,需求下还可以分拆任务,页面要展现的字段有20多个,而且需求采用通用表单设计,db采用大宽表存储,有一百多个字段.目前数据量不大,第一版采用普通的 ...
- 00-IT人士必去的10个网站
IT人士必去的10个网站 1.Chinaunix 网址:http://www.chinaunix.net/ 简介:中国最大的linux/unix技术社区. 2.ITPub 网址:http://www. ...
