codefroces 7C
1 second
256 megabytes
standard input
standard output
A line on the plane is described by an equation Ax + By + C = 0. You are to find any point on this line, whose coordinates are integer numbers from - 5·1018 to 5·1018 inclusive, or to find out that such points do not exist.
The first line contains three integers A, B and C ( - 2·109 ≤ A, B, C ≤ 2·109) — corresponding coefficients of the line equation. It is guaranteed that A2 + B2 > 0.
If the required point exists, output its coordinates, otherwise output -1.
2 5 3
6 -3
(哇,第一次在cf上做到模板题
题意:拓展欧几里得求解ax+by=c的模板题
附ac代码:
1 #include <cstdio>
2 #include <cstring>
3 #include <string>
4 #include <iostream>
5 #include <algorithm>
6 using namespace std;
7 typedef long long ll;
8 int gcd(ll a,ll b)
9 {
10 return b==0?a:gcd(b,a%b);
11 }
12 void exgcd(ll a,ll b,ll &x,ll &y)
13 {
14 ll d;
15 if(!b)
16 {
17 d=a;
18 x=1;
19 y=0;
20 }
21 else
22 {
23 exgcd(b,a%b,y,x);
24 y-=x*(a/b);
25 }
26 }
27 int main()
28 {
29 ios::sync_with_stdio(false);
30 cin.tie(0);
31 cout.tie(0);
32 ll a,b,c;
33 ll x,y;
34 cin>>a>>b>>c;
35 c=-c;
36 ll d=gcd(a,b);
37 if(c%d)
38 cout<<-1<<endl;
39 else
40 {
41 a/=d;b/=d;c/=d;
42 exgcd(a,b,x,y);
43 cout<<x*c<<" "<<y*c<<endl;
44 }
45
46 return 0;
47 }
codefroces 7C的更多相关文章
- SuperMap iClient 7C——网络客户端GIS开发平台 产品新特性
SuperMap iClient 7C是空间信息和服务的可视化交互开发平台,是SuperMap服务器系列产品的统一客户端.产品基于统一的架构体系,面向Web端和移动端提供了多种类型的SDK开发包,帮助 ...
- 解题报告:codeforce 7C Line
codeforce 7C C. Line time limit per test1 second memory limit per test256 megabytes A line on the pl ...
- Codefroces 1328E Tree Querie(dfs序)
Codefroces 1328E Tree Querie 题目 给出一棵1为根,n个节点的树,每次询问\(k_i\) 个节点,问是否存在这样一条路径: 从根出发,且每个节点在这条路径上或者距离路径的距 ...
- Codefroces 750D:New Year and Fireworks(BFS)
http://codeforces.com/contest/750/problem/D 题意:烟花会绽放n次,每次会向前推进t[i]格,每次绽放会向左右45°绽放,问有烟花的格子数. 思路:n = 3 ...
- Codefroces 750C:New Year and Rating(思维)
http://codeforces.com/contest/750/problem/C 题意:有n场比赛,每场比赛有一个c,代表比赛结束后分数的增长情况,有一个d,代表这场比赛在div1或者div2打 ...
- codefroces 589A
time limit per testsecondsmemory limit per testmegabytesinputstandard inputoutputstandard outputPoly ...
- CF 7C. Line(扩展欧几里德)
题目链接 AC了.经典问题,a*x+b*y+c = 0整数点,有些忘记了扩展欧几里德,复习一下. #include <cstdio> #include <iostream> # ...
- 李洪强-C语言7-C语言运算符
C语言运算符 一.算术运算 C语言一共有34种运算符,包括常见的加减乘除运算. ①. 加法:+ 还可以表示正号 ②. 减法:- 还可以表示负号 ③. 乘法:* 非数学意义上的X ④. 除法:/ 注意 ...
- Codefroces Gym 100781A(树上最长路径)
http://codeforces.com/gym/100781/attachments 题意:有N个点,M条边,问对两两之间的树添加一条边之后,让整棵大树最远的点对之间的距离最近,问这个最近距离是多 ...
随机推荐
- 陈思淼:阿里6个月重写Lazada,再造“淘宝”的技术总结
小结: 1. 所谓的中台技术,就是从 IDC,网络,机房,操作系统,中间件,数据库,算法平台,数据平台,计算平台,到业务平台,每一层都有清晰的定义和技术产品. 具体来看,首先,集团技术的分层和每层的产 ...
- centralized collectors 中心化 采集器
Fluent Bit https://fluentbit.io/ FluentBit is an open source specialized data collector. It provides ...
- Jenkins部署springboot项目
记录jenkins如何部署springboot项目(jar类型的) 一.首先需要先配置好jenkins的基本配置(jdk.maven--),可在系统管理-->>全局工具配置中进行配置. 配 ...
- AutoMapper源码解析
研究AutoMapper源码前,我们先来看一下AutoMapper的作用 官网解释:AutoMapper是一个简单的小程序库,旨在解决看似复杂的问题-摆脱将一个对象映射到另一个对象的代码 解释 首先一 ...
- Go - 实现项目内链路追踪
为什么项目内需要链路追踪?当一个请求中,请求了多个服务单元,如果请求出现了错误或异常,很难去定位是哪个服务出了问题,这时就需要链路追踪. 从图中可以清晰的看出他们之间的调用关系,通过一个例子说明下链路 ...
- 【译】Async/Await(四)—— Pinning
原文标题:Async/Await 原文链接:https://os.phil-opp.com/async-await/#multitasking 公众号: Rust 碎碎念 翻译 by: Praying ...
- SparkSql 数据类型转换
SparkSql 数据类型转换 1.SparkSql数据类型 1.1数字类型 1.2复杂类型 2.Spark Sql数据类型和Scala数据类型对比 3.Spark Sql数据类型转换案例 3.1获取 ...
- c++指针 c指针 改变值
1. #include <iostream>using namespace std;void move(int *p) ====>void move(*&p){ ...
- C++类基本--随笔二
1 #include <iostream> 2 #include <string.h> 3 using namespace std; 4 5 class Internet 6 ...
- OpenStack (neutron 网络服务)
neutron介绍 提供 OpenStack 虚拟网络服务,也是 OpenStack 重要的核心模块之一,该模块最开始是 Nova 的一部分,叫 nova-network,后来从 Nova 中分离出来 ...