Line

题目:

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

2 5 3

Output

6 -3

 

题意:

解二元一次方程,存在输出该解,不存在输出-1

 

思路:

将ax+by+c=0,化为ax+by=-c/gcd(a,b)*gcd(a,b),套拓展欧几里得就行;

 

代码:

#include<stdio.h>
long long cifang(long long a,long long b,long long &x,long long &y)
{
	if(b==0)
	{
		x = 1;
		y = 0;
		return a;
	}
	long long t;
	t = cifang(b,a%b,x,y);
	long long temp = y;
	y = x-(a/b)*y;
	x  = temp;
	return t;
}
int main()
{
	long long i,j,a,b,c;
	while(~scanf("%lld%lld%lld",&a,&b,&c))
	{
		long long x,y;
		long long t =cifang(a,b,x,y);
		if(-c%t!=0)
			printf("-1\n");
		else printf("%lld %lld\n",(-c)/t*x,(-c)/t*y);
	}
	return 0;
}

 

### 如何在编程或文本处理中拆分行 在编程和文本处理中,拆分行是一种常见的操作。以下是几种实现方法: #### 使用 Python 的字符串分割功能 Python 提供了一个内置的方法 `str.split()` 来按指定分隔符拆分行[^3]。此函数可以基于空白字符(默认)、逗号或其他自定义分隔符来拆分字符串。 ```python line = "This is a sample line" words = line.split() # 默认以空白字符作为分隔符 print(words) ``` 如果需要按照特定字符拆分,则可以在 `split` 方法中传入该字符作为参数。 ```python csv_line = "apple,banana,cherry" fruits = csv_line.split(",") # 按照逗号拆分 print(fruits) ``` #### 处理多行文本 当面对多行文本时,可以使用换行符 `\n` 进行拆分[^4]。 ```python text_block = """First line\nSecond line\nThird line""" lines = text_block.split("\n") print(lines) ``` #### 正则表达式中的拆分行 对于更复杂的场景,正则表达式模块 `re` 可用于依据模式匹配拆分行[^5]。 ```python import re multiline_text = "Line1 Line2 Line3" result = re.split(r'\s+', multiline_text) # 根据一个或多个空白字符拆分 print(result) ``` #### 文件读取时自动拆分行 在文件操作过程中,通常每一行数据会被自然视为独立单元。通过逐行读取的方式可以直接获取已拆分的内容[^6]。 ```python with open('file.txt', 'r') as file: for line in file: print(line.strip()) # 去除每行末尾的换行符并打印 ```
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值