C. Line
time limit per test

1 second

memory limit per test

256 megabytes

input

standard input

output

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.

Input

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.

Output

If the required point exists, output its coordinates, otherwise output -1.

Examples
Input
2 5 3
Output
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的更多相关文章

  1. SuperMap iClient 7C——网络客户端GIS开发平台 产品新特性

    SuperMap iClient 7C是空间信息和服务的可视化交互开发平台,是SuperMap服务器系列产品的统一客户端.产品基于统一的架构体系,面向Web端和移动端提供了多种类型的SDK开发包,帮助 ...

  2. 解题报告:codeforce 7C Line

    codeforce 7C C. Line time limit per test1 second memory limit per test256 megabytes A line on the pl ...

  3. Codefroces 1328E Tree Querie(dfs序)

    Codefroces 1328E Tree Querie 题目 给出一棵1为根,n个节点的树,每次询问\(k_i\) 个节点,问是否存在这样一条路径: 从根出发,且每个节点在这条路径上或者距离路径的距 ...

  4. Codefroces 750D:New Year and Fireworks(BFS)

    http://codeforces.com/contest/750/problem/D 题意:烟花会绽放n次,每次会向前推进t[i]格,每次绽放会向左右45°绽放,问有烟花的格子数. 思路:n = 3 ...

  5. Codefroces 750C:New Year and Rating(思维)

    http://codeforces.com/contest/750/problem/C 题意:有n场比赛,每场比赛有一个c,代表比赛结束后分数的增长情况,有一个d,代表这场比赛在div1或者div2打 ...

  6. codefroces 589A

    time limit per testsecondsmemory limit per testmegabytesinputstandard inputoutputstandard outputPoly ...

  7. CF 7C. Line(扩展欧几里德)

    题目链接 AC了.经典问题,a*x+b*y+c = 0整数点,有些忘记了扩展欧几里德,复习一下. #include <cstdio> #include <iostream> # ...

  8. 李洪强-C语言7-C语言运算符

    C语言运算符 一.算术运算 C语言一共有34种运算符,包括常见的加减乘除运算. ①. 加法:+ 还可以表示正号 ②. 减法:- 还可以表示负号 ③. 乘法:* 非数学意义上的X ④. 除法:/  注意 ...

  9. Codefroces Gym 100781A(树上最长路径)

    http://codeforces.com/gym/100781/attachments 题意:有N个点,M条边,问对两两之间的树添加一条边之后,让整棵大树最远的点对之间的距离最近,问这个最近距离是多 ...

随机推荐

  1. uni-app开发经验分享二十一: 图片滑动解锁插件制作解析

    在开发用户模块的时候,相信大家都碰到过一个功能,图片滑动解锁后发送验证码,这里分享我用uni-app制作的一个小控件 效果如下: 需要如下图片资源 template <template> ...

  2. CoeMonkey少儿编程第4章 变量

    点击这里,现在就开启CodeMonkey的趣味编程之旅. 目标 了解什么是变量 了解变量的命名规则 掌握如何使用变量 变量 什么是变量?顾名思义,变量就是可以变化的量. 和变量相对的是常量,即不可变化 ...

  3. libuv中实现tcp服务器

    目录 1.说明 2.libuv的tcp server 3.API简介 3.1.uv_tcp_init 3.2.uv_ip4_addr 3.3.uv_tcp_bind 3.4.uv_listen 3.5 ...

  4. 前端面试之CSS常用的选择器!

    前端面试之CSS常用的选择器! 标签选择器 <style> /* <!-- 标签选择器 :写上标签名 -->*/ p { color: green; } div { color ...

  5. 写给 Poppy 的 MySQL 速查表

    昨天 Poppy 问我是不是应该学一些网页开发的东西, 我的回答是这样的: 今天花了点时间汇总了一些 MySQL 简单的命令. ======== 正文分割线 ======== 有哪些常见的数据库: O ...

  6. On-the-fly Garbage Collection: an Exercise in Cooperation

    On-the-fly Garbage Collection: an Exercise in Cooperation - Microsoft Research https://www.microsoft ...

  7. 风险识别系统-大数据智能风控管理平台-企业风控解决方案– 阿里云 https://www.aliyun.com/product/saf

    风险识别系统-大数据智能风控管理平台-企业风控解决方案– 阿里云 https://www.aliyun.com/product/saf

  8. 编译安装 codeblocks 20.03 mips64el

    期末考试要用哦,不然谁会愿意去踩这么多坑. qaq 龙梦 Fedora28 中有 codeblocks 17.12,但是 Ctrl-v 粘贴会闪退,导致压根不能用.Bing了一下发现这其实是 code ...

  9. SpringMVC 中 @ControllerAdvice 注解

    SpringMVC 中 @ControllerAdvice 注解 1.@ControllerAdvice 1.1 全局异常处理 1.2 全局数据绑定 1.3 全局数据预处理 原文地址: 江南一点雨:S ...

  10. eclipse中Tomcat修改项目名称

    1.打开你的项目目录,找到一个.project文件,打开后修改<name> test</name>中的值,将test修改成你要修改的名字: 2.在项目目录下,打开.settin ...