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. 域名、IP地址、URL关系

    域名是个文字形式记录的IP地址 IP地址是计算机在网络中的门牌号! URL是网页地址 例如1: http://zhidao.baidu.com/question/14674128.html 是URL ...

  2. lintcode100 删除排序数组中的重复数字

    删除排序数组中的重复数字   给定一个排序数组,在原数组中删除重复出现的数字,使得每个元素只出现一次,并且返回新的数组的长度. 不要使用额外的数组空间,必须在原地没有额外空间的条件下完成. 您在真实的 ...

  3. n! 阶乘

    其实1.2.3.4.6.7…都是可以不用考虑的,因此选择以5为迭代步数即可. 首先,这些数字都可以不用进行%5(对5取余数)运算,因此每次循环时可以直接将函数的count变量直接加1.其次,考虑25. ...

  4. jquery取radio单选按钮

    // var strMess = '<%=Exchange() %>';//            if (strMess == "兑换成功") {//         ...

  5. Ext JS 6学习文档-第6章-高级组件

    Ext JS 6学习文档-第6章-高级组件 高级组件 本章涵盖了高级组件,比如 tree 和 data view.它将为读者呈现一个示例项目为 图片浏览器,它使用 tree 和 data view 组 ...

  6. JQuery中each方法实现

    each()函数是基本上所有的框架都提供了的一个工具类函数,通过它,你可以遍历对象.数组的属性值并进行处理. jQuery和jQuery对象都实现了该方法,对于jQuery对象,只是把each方法简单 ...

  7. iOS AVAudioPlayer播放音频时声音太小

    iOS AVAudioPlayer播放音频时声音太小 //引入AVFoundation类库,设置播放模式就可以了 do { try AVAudioSession.sharedInstance().ov ...

  8. error : Web 项目“RealEstate.Web”的 URL“http://localhost:20000”已配置为将 IIS 用作 Web 服务器,但是当前在 IIS Express W

    error  : Web 项目"RealEstate.Web"的 URL"http://localhost:20000"已配置为将 IIS 用作 Web 服务器 ...

  9. PAT L1-039 古风排版

    https://pintia.cn/problem-sets/994805046380707840/problems/994805091888906240 中国的古人写文字,是从右向左竖向排版的.本题 ...

  10. Delphi XE4 TStringHelper用法详解

    原文地址:Delphi XE4 TStringHelper用法详解作者:天下为公 Delphi XE4的TStringHelper,对操作字符串进一步带来更多的方法,估计XE5还能继续用到. Syst ...