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 AB 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

Copy
2 5 3
output

Copy
6 -3

ax+by+c=0,化为ax+by=-c/gcd(a,b)*gcd(a,b),

套拓展欧几里得就可以解出了

 #include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + ;
const int mod = 1e9 + ;
typedef long long LL;
LL exgcd(LL a, LL b, LL &x, LL &y) {
if (b == ) {
x = , y = ;
return a;
}
LL g = exgcd(b, a % b, x, y);
LL t;
t = x, x = y, y = t - (a / b) * y;
return g;
}
int main() {
LL a, b, c, x, y;
cin >> a >> b >> c;
LL t = exgcd(a, b, x, y);
if (c % t == ) printf("%lld %lld\n", -x * c / t, -y * c / t);
else printf("-1\n");
return ;
}

C. Line (扩展欧几里得)的更多相关文章

  1. Line(扩展欧几里得)

    题意:本题给出一个直线,推断是否有整数点在这条直线上: 分析:本题最重要的是在给出的直线是不是平行于坐标轴,即A是不是为0或B是不是为0..此外.本题另一点就是C输入之后要取其相反数,才干进行扩展欧几 ...

  2. Codeforces7C 扩展欧几里得

    Line Time Limit: 1000MS   Memory Limit: 262144KB   64bit IO Format: %I64d & %I64u Submit Status ...

  3. POJ2115(扩展欧几里得)

    C Looooops Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 23700   Accepted: 6550 Descr ...

  4. Root(hdu5777+扩展欧几里得+原根)2015 Multi-University Training Contest 7

    Root Time Limit: 30000/15000 MS (Java/Others)    Memory Limit: 262144/262144 K (Java/Others)Total Su ...

  5. UVA 10090 Marbles(扩展欧几里得)

    Marbles Input: standard input Output: standard output I have some (say, n) marbles (small glass ball ...

  6. [ACM] hdu 3923 Invoker (Poyla计数,高速幂运算,扩展欧几里得或费马小定理)

    Invoker Problem Description On of Vance's favourite hero is Invoker, Kael. As many people knows Kael ...

  7. Root(hdu5777+扩展欧几里得+原根)

    Root                                                                          Time Limit: 30000/1500 ...

  8. Gym100812 L 扩展欧几里得

    L. Knights without Fear and Reproach time limit per test 2.0 s memory limit per test 256 MB input st ...

  9. Intel Code Challenge Final Round (Div. 1 + Div. 2, Combined) C.Ray Tracing (模拟或扩展欧几里得)

    http://codeforces.com/contest/724/problem/C 题目大意: 在一个n*m的盒子里,从(0,0)射出一条每秒位移为(1,1)的射线,遵从反射定律,给出k个点,求射 ...

  10. UVA 12169 Disgruntled Judge 枚举+扩展欧几里得

    题目大意:有3个整数 x[1], a, b 满足递推式x[i]=(a*x[i-1]+b)mod 10001.由这个递推式计算出了长度为2T的数列,现在要求输入x[1],x[3],......x[2T- ...

随机推荐

  1. python终极篇 ---django 模板系统

                                                模板系统                                                . MV ...

  2. 关闭Tomcat进程 一条语句(必看)

    写在开始 MAC系统下进行JAVA研发,经常遇到的一个问题就是杀死异常Tomcat 通常都是用两条指令,先查询出Tomcat占用的进程,再kill掉该进程, 其实有一种联合语句的方式可以一条语句直接关 ...

  3. Coprime Sequence(前后缀GCD)

    Description Do you know what is called ``Coprime Sequence''? That is a sequence consists of $n$ posi ...

  4. 接口文档管理工具-Postman、Swagger、RAP(转载)

    接口文档管理工具-Postman.Swagger.RAP 转自:http://www.51testing.com/html/10/n-3715910.html 在项目开发测试中,接口文档是贯穿始终的. ...

  5. Android - 按钮组件详解

    总结了Android中常用的按钮用法 示例源码下载地址 : -- CSDN :  http://download.csdn.net/detail/han1202012/6852091 -- GitHu ...

  6. 1001 Duplicate Pair

    1.题目戳这里 2.代码: #include<stdio.h> #include<string.h> int main() { int n; while(scanf(" ...

  7. TCP系列27—窗口管理&流控—1、概述

    在前面的内容中我们依次介绍了TCP的连接建立和终止过程和TCP的各种重传方式.接着我们在这部分首先关注交互式应用TCP连接相关内容如延迟ACK.Nagle算法.Cork算法等,接着我们引入流控机制(f ...

  8. Qt应用程序图标

    版权声明:若无来源注明,Techie亮博客文章均为原创. 转载请以链接形式标明本文标题和地址: 本文标题:Qt应用程序图标     本文地址:http://techieliang.com/2017/1 ...

  9. PAT-2018年冬季考试-乙级

    1091 N-自守数 代码: #include <bits/stdc++.h> using namespace std; int T; int A(int a) { ; while(a) ...

  10. RabbitMQ安装与初始配置【转载】

    Erlang安装 rabbitmq依赖于Erlang,需先安装,推荐安装rabbitmq/erlang-rpm: #clone源码 git clone https://github.com/rabbi ...