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. SAP 技术设置(technical setting)

    在创建数据库表的时候,需要设置它的技术参数:这样才能使用. 在技术设置里,有个数据类(data class),如APPL0,等等. 有好多值可以供我们选择.这些值保存在表DDART中,表的描述:DD: ...

  2. node集群(cluster)

    使用例子 为了让node应用能够在多核服务器中提高性能,node提供cluster API,用于创建多个工作进程,然后由这些工作进程并行处理请求. // master.js const cluster ...

  3. 翻页bug 在接口文档中应规范参数的取值区间 接口规范

    <?php$a=array("red","green","blue","yellow","brown&q ...

  4. 小步前进之WebService

    WebService Web Service 什么是Web Service? 为什么使用Web Service XML 什么是XML? 为什么使用XML? SOAP(Simple Object Acc ...

  5. deepin定制deepin-terminal

    一. 背景介绍 本人以前在win10上经常使用xshell来登陆服务器.xshell提供了很丰富的功能和快捷键.个人比较喜欢的包括三个功能 终端透明 双击时根据分隔符选中文字 突出显示 但是自从使用d ...

  6. 题解 P3833 【[SHOI2012]魔法树】

    题目 直通车 很显然这是个树刨的板子,树上链查询和子树查询 注意: 1.这个点的树根为 0 而不是 1 所以注意读图时点标号 +1 就解决了 2.注意数据范围\(2^{32}\) 然后板子就能过了 n ...

  7. HDU3062 PARTY

    Party Problem Description 有n对夫妻被邀请参加一个聚会,因为场地的问题,每对夫妻中只有1人可以列席.在2n 个人中,某些人之间有着很大的矛盾(当然夫妻之间是没有矛盾的),有矛 ...

  8. LOJ1036

    AHOI 2008 聚会 Y 岛风景美丽宜人,气候温和,物产丰富.Y 岛上有 N 个城市,有 N-1 条城市间的道路连接着它们.每一条道路都连接某两个城市.幸运的是,小可可通过这些道路可以走遍 Y 岛 ...

  9. SpringMVC听课笔记(七:Restful CRUD)

    这章貌似没有什么可讲的,可以看GitHub工程代码: https://github.com/heyboom/SpringMVC_Rest_CRUD

  10. 二:整合Spring Security

    整合Spring Security 1.项目创建 2.初次体验 3.用户名配置 3.1 配置文件配置用户名/密码 3.2 Java 配置用户名/密码 4.登录配置 5.忽略拦截 江南一点雨:Sprin ...