codeforce 7C

C. Line

time limit per test1 second

memory limit per test256 megabytes

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

代码如下:
#include <iostream>

using namespace std;
typedef long long ll; ll ex_gcd(ll a, ll b, ll&x, ll&y)
{
if(b == 0)
{
x = 1;
y = 0;
return a;
}
int ans = ex_gcd(b,a%b,x,y);
int tmp = x;
x = y;
y = tmp - a/b * y;
return ans;
}
int main()
{
ll x, y;
ll a, b, c;
cin >> a >> b >> c;
c *= -1;
ll gcd = ex_gcd(a,b,x,y);
if(c%gcd)
{
cout << "-1" << endl;
}
else
{
int k = c/gcd;
x *= k;
y *= k;
cout << x << " " << y << endl;
} return 0;
}

扩展欧几里得算法

解题报告:codeforce 7C Line的更多相关文章

  1. LeetCode 解题报告索引

    最近在准备找工作的算法题,刷刷LeetCode,以下是我的解题报告索引,每一题几乎都有详细的说明,供各位码农参考.根据我自己做的进度持续更新中......                        ...

  2. ACM: Just a Hook 解题报告 -线段树

    E - Just a Hook Time Limit:2000MS     Memory Limit:32768KB     64bit IO Format:%I64d & %I64u   D ...

  3. Facebook Hacker Cup 2014 Qualification Round 竞赛试题 Square Detector 解题报告

    Facebook Hacker Cup 2014 Qualification Round比赛Square Detector题的解题报告.单击这里打开题目链接(国内访问需要那个,你懂的). 原题如下: ...

  4. C-C Radar Installation 解题报告

    C-C    Radar Installation   解题报告 题目链接:http://acm.hust.edu.cn/vjudge/contest/view.action?cid=86640#pr ...

  5. 2015 Multi-University Training Contest 6 solutions BY ZJU(部分解题报告)

    官方解题报告:http://bestcoder.hdu.edu.cn/blog/2015-multi-university-training-contest-6-solutions-by-zju/ 表 ...

  6. ZOJ_3950_How Many Nines 解题报告及如何对程序进行测试修改

    The 17th Zhejiang University Programming Contest Sponsored by TuSimple Solution: #include <stdio. ...

  7. HDU 4303 Hourai Jeweled 解题报告

    HDU 4303 Hourai Jeweled 解题报告 评测地址: http://acm.hdu.edu.cn/showproblem.php?pid=4303 评测地址: https://xoj. ...

  8. CYJian的水题大赛2 解题报告

    这场比赛是前几天洛谷上 暮雪﹃紛紛dalao的个人公开赛,当时基本上都在水暴力分......也没有好好写正解(可能除了T1) 过了几天颓废的日子之后,本蒟蒻觉得应该卓越一下了qwq,所以就打算写一个解 ...

  9. ACM-ICPC 2017 Asia HongKong 解题报告

    ACM-ICPC 2017 Asia HongKong 解题报告 任意门:https://nanti.jisuanke.com/?kw=ACM-ICPC%202017%20Asia%20HongKon ...

随机推荐

  1. MYSQL--表分区、查看分区(转)

    一.       mysql分区简介 数据库分区 数据库分区是一种物理数据库设计技术.虽然分区技术可以实现很多效果,但其主要目的是为了在特定的SQL操作中减少数据读写的总量以缩减sql语句的响应时间, ...

  2. etcd: request cluster ID mismatch错误解决【只适用于新建etcd集群或无数据集群】

    1.报错信息 Mar 29 05:45:31 xxx etcd: request cluster ID mismatch (got 414f8613693e2e2 want cdf818194e3a8 ...

  3. swagger接口变动监控

    版本与版本之间迭代,总会发生接口的变化,而这些变化开发不会都告诉测试,测试需要把全部接口检查一遍,这样就降低了测试效率. 为了解决这个问题,结合公司实际项目进行了以下设计: 1.对比测试环境swagg ...

  4. window下的开发环境:常用软件

    window下的开发环境:常用软件 Visio 2010  - 产品设计 xmind        -产品设计 Axure       -产品设计 Edraw max 7.3(破解版)  -产品设计 ...

  5. Java编程:将具有父子关系的数据库表数据转换为树形结构,支持无限层级

    在平时的开发工作中,经常遇到这样一个场景,在数据库中存储了具有父子关系的数据,需要将这些数据以树形结构的形式在界面上进行展示.本文的目的是提供了一个通用的编程模型,解决将具有父子关系的数据转换成树形结 ...

  6. Java基础—输入输出流

    流的概念 在Java中,流是从源到目的地的字节的有序序列.Java中有两种基本的流——输入流(InputStream)和输出流(OutputStream). 根据流相对于程序的另一个端点的不同,分为节 ...

  7. usb-tooltip 重写.tooltip { word-break: break-all; }解决单词内换行

    <div style="padding: 5px 10px; font-size: 16px; text-align: left" class="truncate& ...

  8. [CentOS] 常用工具软件包

    gcc & g++ & gdb • 安装方法 yum install gcc -y yum install gcc-c++ -y         yum install gdb -y ...

  9. Python:6种标准数据类型

    原文地址https://www.cnblogs.com/qin1991/p/5910145.html #!/usr/bin/python3 #python的基本语法和数据类型 #python3中 一行 ...

  10. sqlserver 2005/2008 导入超大sql文件

    SQLCMD -E -dmaster -ic:\Scripts\create_db.sql 安装了Microsoft® SQL Server® 2008 R2 Native Client可用