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
  1. 2 5 3
Output
  1. 6 -3

    (哇,第一次在cf上做到模板题

    题意:拓展欧几里得求解ax+by=c的模板题

    ac代码:
  1. 1 #include <cstdio>
  2. 2 #include <cstring>
  3. 3 #include <string>
  4. 4 #include <iostream>
  5. 5 #include <algorithm>
  6. 6 using namespace std;
  7. 7 typedef long long ll;
  8. 8 int gcd(ll a,ll b)
  9. 9 {
  10. 10 return b==0?a:gcd(b,a%b);
  11. 11 }
  12. 12 void exgcd(ll a,ll b,ll &x,ll &y)
  13. 13 {
  14. 14 ll d;
  15. 15 if(!b)
  16. 16 {
  17. 17 d=a;
  18. 18 x=1;
  19. 19 y=0;
  20. 20 }
  21. 21 else
  22. 22 {
  23. 23 exgcd(b,a%b,y,x);
  24. 24 y-=x*(a/b);
  25. 25 }
  26. 26 }
  27. 27 int main()
  28. 28 {
  29. 29 ios::sync_with_stdio(false);
  30. 30 cin.tie(0);
  31. 31 cout.tie(0);
  32. 32 ll a,b,c;
  33. 33 ll x,y;
  34. 34 cin>>a>>b>>c;
  35. 35 c=-c;
  36. 36 ll d=gcd(a,b);
  37. 37 if(c%d)
  38. 38 cout<<-1<<endl;
  39. 39 else
  40. 40 {
  41. 41 a/=d;b/=d;c/=d;
  42. 42 exgcd(a,b,x,y);
  43. 43 cout<<x*c<<" "<<y*c<<endl;
  44. 44 }
  45. 45
  46. 46 return 0;
  47. 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. Spring学习03

    6.Bean的自动装配 6.1 自动装配说明 自动装配是使用spring满足bean依赖的一种方法 spring会在应用上下文中为某个bean寻找其依赖的bean. Spring中bean的三种装配机 ...

  2. python Mysql 多条件查询

    做项目时,遇到一场景,前端至少传入一个参数,最多传入四个参数,根据单参数或者组合参数,从数据库筛选数据. 作为一个小白,思考之,从数学的角度,\(C_4^1 + C_4^2+C_4^3+C_4^4=1 ...

  3. 获取Java线程转储的常用方法

    1. 线程转储简介 线程转储(Thread Dump)就是JVM中所有线程状态信息的一次快照. 线程转储一般使用文本格式, 可以将其保存到文本文件中, 然后人工查看和分析, 或者使用工具/API自动分 ...

  4. COLMAP简易教程(命令行模式)

    完整的 multi view stereo pipeline 会有以下步骤 structure from motion(SfM)==> camera parameters, sparse poi ...

  5. JavaFx ObservableList的使用详解

    原文地址:JavaFx ObservableList的使用详解 | Stars-One的杂货小窝 最近在研究MVVM模式,发现可以将之前写的FxRecyclerView控件改造一下,便是开始尝试,尝试 ...

  6. WPF权限控制——【1】界面布局

    本来就不怎么喜欢写博客,好不容易申请了博客园的账号,迈出了先前没有跨越的第一步:转眼间几年的时间就过去了,还是空空如也.今天的心境是这样的,发现wpf相关的资料及源码实在不多,就想写下随笔:一方面是自 ...

  7. oblet

      oblet - The Go Programming Language https://golang.google.cn/search?q=oblet // put enqueues a poin ...

  8. KDB调试 — ARM

    1        寄存器 1.1         通用寄存器 A64指令集可以看到31个64位通用(整数)寄存器,分别是R0-R30. 在64位上下文中,这些寄存器通常使用名称x0-x30来表示; 在 ...

  9. VS Code 使用教程详解

    一.写在前面 1.为什么选择 \(VS\) \(code\) 一款非常好用的代码编辑器 标准化 \(Language\) \(Service\) \(Protocol\) 内置调试器和标准化 \(De ...

  10. apache 创建多端口监听

    httpd.conf 将 #LoadModule vhost_alias_module modules/mod_vhost_alias.so 改为 LoadModule vhost_alias_mod ...