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条边,问对两两之间的树添加一条边之后,让整棵大树最远的点对之间的距离最近,问这个最近距离是多 ...
随机推荐
- 入门OJ:最短路径树入门
题目描述 n个城市用m条双向公路连接,使得任意两个城市都能直接或间接地连通.其中城市编号为1..n,公路编号为1..m.任意个两个城市间的货物运输会选择最短路径,把这n*(n-1)条最短路径的和记为S ...
- 日常分享:关于时间复杂度和空间复杂度的一些优化心得分享(C#)
前言 今天分享一下日常工作中遇到的性能问题和解决方案,比较零碎,后续会持续更新(运行环境为.net core 3.1) 本次分享的案例都是由实际生产而来,经过简化后作为举例 Part 1(作为简单数据 ...
- 【原创】Linux虚拟化KVM-Qemu分析(八)之virtio初探
背景 Read the fucking source code! --By 鲁迅 A picture is worth a thousand words. --By 高尔基 说明: KVM版本:5.9 ...
- apscheduler(定时任务) 基于redis持久化配置操作
apscheduler(定时任务) 基于redis持久化配置操作 安装模块 pip install apscheduler 导入模块配置 ## 配置redis模块 from apscheduler.j ...
- CMOS 摄像头的Skipping 和 Binning 模式
在通常的摄像头中,不同的resolution对应不同的帧率.想要提高帧率就要考虑是否需要缩小视野(FOV).若不希望视野缩小,就需要减少resolution. 常用的减少resolution的两种方式 ...
- 406 UDP协议是面向非连接的协议 Keep-Alive
HTTP The Definitive Guide Table 3-1. Common HTTP methods Method Description Message body? GET ...
- You shouldn't use *any* general-purpose hash function for user passwords, not BLAKE2, and not MD5, SHA-1, SHA-256, or SHA-3
hashlib - Secure hashes and message digests - Python 3.8.3 documentation https://docs.python.org/3.8 ...
- The WebSocket Protocol 1000
https://tools.ietf.org/html/rfc6455 https://tools.ietf.org/html/rfc6455 7.4.1. Defined Status Codes ...
- eclipse中Tomcat修改项目名称
1.打开你的项目目录,找到一个.project文件,打开后修改<name> test</name>中的值,将test修改成你要修改的名字: 2.在项目目录下,打开.settin ...
- 安装superset
1.首先去Anaconda官网下载安装脚本 Anaconda3-2019.07-Linux-x86_64.sh 2.上传Anaconda3-2019.07-Linux-x86_64.sh 将Anaco ...