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 ...
随机推荐
- ROS-URDF仿真
前言:URDF (标准化机器人描述格式),是一种用于描述机器人及其部分结构.关节.自由度等的XML格式文件. 一.首先做一个带有四个轮子的机器人底座. 1.1 新建urdf文件 在chapter4_t ...
- 多维DP UVA 11552 Fewest Flop
题目传送门 /* 题意:将子符串分成k组,每组的字符顺序任意,问改变后的字符串最少有多少块 三维DP:可以知道,每一组的最少块是确定的,问题就在于组与组之间可能会合并块,总块数会-1. dp[i][j ...
- 二分图最大匹配(匈牙利算法) UVA 670 The dog task
题目传送门 /* 题意:bob按照指定顺序行走,他的狗可以在他到达下一个点之前到一个景点并及时返回,问狗最多能走多少个景点 匈牙利算法:按照狗能否顺利到一个景点分为两个集合,套个模板 */ #incl ...
- Q - Euclid in Manhattan(欧几里德距离==曼哈顿距离?)
Desciption Consider a set of n points in a 2-D plane with integer coordinates. There are various way ...
- ACM_下一个排列
The Next Permutation Time Limit: 2000/1000ms (Java/Others) Problem Description: For this problem, yo ...
- Linux环境下修改MySQL数据库存储引擎
今天在执行Oracle数据库迁移至MySQL数据库时报出了一个错误信息: Specified key was too bytes 百度发现,原来需要更改MySQL数据库的存储引擎为InnoDB,查询目 ...
- 设计模式学习之代理模式(Proxy)
一.代理模式的初衷 不想让客户端直接访问具体实现接口,客户端不应该直接访问具体实现,一般会涉及到以下四个对象 业务接口:定义客户端访问的接口,是实现类和代理类都需要实现的 实现类:实现了业务接口,真正 ...
- error: no such device : 76de62ec-ac60-4c4d-bb Entering rescue mode .. grub resuce>(系统硬盘驱动器MBR已损坏)问题解决办法(图文详解)
问题详情 近期,由于博主我,担任实验室整个大数据集群的leader,突然的断电给整个集群造成,如下的情况问题.(欲哭无泪,我的各种服务啊) 解决办法 第一种方法:尝试,直接重启机器(我这里是台式机 ...
- C#知识点-反射
一.开发环境 操作系统:Win7 编译器:VS2010 .net版本:.net4.0 二.项目结构 三.开发流程 0.编写实体类 namespace ReflectDemo { public clas ...
- C/C++ char*、char[]
一.本质区别 char* s是一个保存字符串首地址的指针变量,char a[]是许多连续的内存单元,单元中的元素为char类型.之所以用char *能达到char []的效果,还是字符串的本质,即给你 ...
