解题报告:codeforce 7C Line
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的更多相关文章
- LeetCode 解题报告索引
最近在准备找工作的算法题,刷刷LeetCode,以下是我的解题报告索引,每一题几乎都有详细的说明,供各位码农参考.根据我自己做的进度持续更新中...... ...
- ACM: Just a Hook 解题报告 -线段树
E - Just a Hook Time Limit:2000MS Memory Limit:32768KB 64bit IO Format:%I64d & %I64u D ...
- Facebook Hacker Cup 2014 Qualification Round 竞赛试题 Square Detector 解题报告
Facebook Hacker Cup 2014 Qualification Round比赛Square Detector题的解题报告.单击这里打开题目链接(国内访问需要那个,你懂的). 原题如下: ...
- C-C Radar Installation 解题报告
C-C Radar Installation 解题报告 题目链接:http://acm.hust.edu.cn/vjudge/contest/view.action?cid=86640#pr ...
- 2015 Multi-University Training Contest 6 solutions BY ZJU(部分解题报告)
官方解题报告:http://bestcoder.hdu.edu.cn/blog/2015-multi-university-training-contest-6-solutions-by-zju/ 表 ...
- ZOJ_3950_How Many Nines 解题报告及如何对程序进行测试修改
The 17th Zhejiang University Programming Contest Sponsored by TuSimple Solution: #include <stdio. ...
- HDU 4303 Hourai Jeweled 解题报告
HDU 4303 Hourai Jeweled 解题报告 评测地址: http://acm.hdu.edu.cn/showproblem.php?pid=4303 评测地址: https://xoj. ...
- CYJian的水题大赛2 解题报告
这场比赛是前几天洛谷上 暮雪﹃紛紛dalao的个人公开赛,当时基本上都在水暴力分......也没有好好写正解(可能除了T1) 过了几天颓废的日子之后,本蒟蒻觉得应该卓越一下了qwq,所以就打算写一个解 ...
- ACM-ICPC 2017 Asia HongKong 解题报告
ACM-ICPC 2017 Asia HongKong 解题报告 任意门:https://nanti.jisuanke.com/?kw=ACM-ICPC%202017%20Asia%20HongKon ...
随机推荐
- SpringBoot 配置文件 YML/Profile
1. 全局配置文件 application.properties application.yml 配置文件名是固定的; 配置文件存放在src/main/resources目录或者类路径/config下 ...
- git学习——<四>git版本管理
一.git版本管理的优势 都说git比svn强大,强大在哪呢? 首先,从部署上说:svn.cvs都是集中式的,一台服务器上部署服务,所有客户端编写的代码都要提交到该服务器上.git是分布式的,所有人都 ...
- 图解HTTP之HTTPS详解
背景:随着越来越多的主流网站已经使用了HTTPS,作为服务器端开发者,就必须了解HTTPS的优势与劣势. 在HTTP协议中有可能存在信息窃听或身份伪装等问题,而使用HTTPS通信机制可以有效地防止这些 ...
- python argparse命令行参数
测试: 第一个没有任何输出和出错 第二个测试为打印帮助信息,argparse会自动生成帮助文档 第三个测试为未定义的-v参数,会出错 第四个测试为未定义的参数foo,出错 positional arg ...
- ftp 服务器搭建
一.安装 yum -y install vsftpd //通过yum来安装vsftpd chkconfig vsftpd on //设置为开机启动 vi /etc/vsftpd/vsftpd.conf ...
- docker部署oracle
oracle部署 创建oracle用户 [root@stpass-15 ~]# useradd oracle[root@stpass-15 oracle]# cd oracle [root@stpas ...
- testng的@Factory及其与@DataProvider的区别
Factory,顾名思意就是工厂,也就是工厂方法,在软件开发中一般结合多态使用,用来根据不同的条件创建不同的类对象. 在这里,Factory一般用来创建一个测试类的多个实例,每个实例属性不同,以执行不 ...
- Jmeter(一)http接口添加header和cookie
HTTP信息头管理器在Jmeter的使用过程中起着很重要的作用,通常我们在通过Jmeter向服务器发送http请求(get或者post)的时候,往往后端需要一些验证信息,比如说web服务器需要带过去c ...
- Zookeeper概述和基本概念
一.Zookeeper背景 随着互联网技术的发展,企业对计算机系统的计算,存储能力要求越来越高,各大IT企业都在追求高并发,海量存储的极致,在这样的背景下,单纯依靠少量高性能单机来完成计算机,云计算的 ...
- Windows常见宏的使用
WIN32_LEAN_AND_MEAN 1. 参考资料:https://msdn.microsoft.com/en-us/library/windows/desktop/aa383745(v=vs. ...