题意:本题给出一个直线,推断是否有整数点在这条直线上;

分析:本题最重要的是在给出的直线是不是平行于坐标轴,即A是不是为0或B是不是为0.。此外。本题另一点就是C输入之后要取其相反数,才干进行扩展欧几里得求解

关于扩展欧几里得详见:http://blog.csdn.net/qq_27599517/article/details/50888092

代码例如以下:

#include <set>
#include <map>
#include <stack>
#include <queue>
#include <math.h>
#include <vector>
#include <utility>
#include <string>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <iostream>
#include <algorithm>
#include <functional> using namespace std;
long long gcd(long long a,long long b){
if(b==0)return a;
return gcd(b,a%b);
}
void _gcd(long long a,long long b,long long &x,long long &y){
if(b==1){
x=1;
y=1-a;
return;
}
else{
long long x1,y1;
_gcd(b,a%b,x1,y1);
x=y1;
y=x1-(a/b)*x;
}
}
int main(){
long long a,b,c;
scanf("%I64d%I64d%I64d",&a,&b,&c);
c=-c;
if(a==0&&b==0){
puts("-1");
return 0;
}
if(a==0&&b!=0){
if(c%b==0){
cout<<0<<" "<<c/b<<endl;
}
else puts("-1");
return 0;
}
if(a!=0&&b==0){
if(c%a==0){
cout<<c/a<<" "<<0<<endl;
}
else puts("-1");
return 0;
}
int g=gcd(a,b);
if(c%g!=0){
puts("-1");
return 0;
}
c/=g;
a/=g;
b/=g;
long long x,y;
_gcd(a,b,x,y);
x=(x*c%b+b)%b;
y=(c-a*x)/b;
cout<<x<<" "<<y<<endl;
return 0;
}

Line(扩展欧几里得)的更多相关文章

  1. Codeforces7C 扩展欧几里得

    Line Time Limit: 1000MS   Memory Limit: 262144KB   64bit IO Format: %I64d & %I64u Submit Status ...

  2. POJ2115(扩展欧几里得)

    C Looooops Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 23700   Accepted: 6550 Descr ...

  3. 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 ...

  4. UVA 10090 Marbles(扩展欧几里得)

    Marbles Input: standard input Output: standard output I have some (say, n) marbles (small glass ball ...

  5. [ACM] hdu 3923 Invoker (Poyla计数,高速幂运算,扩展欧几里得或费马小定理)

    Invoker Problem Description On of Vance's favourite hero is Invoker, Kael. As many people knows Kael ...

  6. Root(hdu5777+扩展欧几里得+原根)

    Root                                                                          Time Limit: 30000/1500 ...

  7. Gym100812 L 扩展欧几里得

    L. Knights without Fear and Reproach time limit per test 2.0 s memory limit per test 256 MB input st ...

  8. 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个点,求射 ...

  9. 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. SimpleMappingExceptionResolver异常映射

    转自:https://blog.csdn.net/qqqqqq654/article/details/65767701 SimpleMappingException异常映射 当异常发生时,我们可以将它 ...

  2. LeetCode Weekly Contest 22

    1. 532. K-diff Pairs in an Array 分析:由于要唯一,所以要去重,考虑k=0,时候,相同的数字需要个数大于1,所以,先用map统计个数,对于k=0,特判,对于其他的,遍历 ...

  3. Hadoop MapReduce编程 API入门系列之网页流量版本1(二十一)

    不多说,直接上代码. 对流量原始日志进行流量统计,将不同省份的用户统计结果输出到不同文件. 代码 package zhouls.bigdata.myMapReduce.areapartition; i ...

  4. [Offer收割]编程练习赛36

    逃离单身节 #include<stdio.h> #include<string.h> #include<stdlib.h> #include<vector&g ...

  5. hdu3861 The King’s Problem 强连通缩点+DAG最小路径覆盖

    对多校赛的题目,我深感无力.题目看不懂,英语是能懂的,题目具体的要求以及需要怎么做没有头绪.样例怎么来的都不明白.好吧,看题解吧. http://www.cnblogs.com/kane0526/ar ...

  6. MFC常用控件之列表视图控件(List Control)

    近期学习了鸡啄米大神的博客,对其中的一些知识点做了一些自己的总结.不过,博客内容大部分来自鸡啄米.因此,这个博客算是转载博客,只是加了一些我自己的理解而已.若想学习鸡啄米大神的博客总结,请点击连接:h ...

  7. nginx配置和测试

    测试nginx处理能力和IO读写能力,使用工具webbench.iozone. 1.nginx测试 使用webbench工具,增加并发量,时间分别取30s,60s 1.webbench -c 200 ...

  8. 使用DOS命令查找包含某一字符串的所有文件

      在windows系统下,来查找并修改指定目录下包含某一字符串的所有文件,麻烦又费时.其实在DOS命令中,提供了Findstr命令来查找指定的一个或多个文件文件中包含(或通过参数 /V来控制不包含) ...

  9. Pyhton学习——Day3

    # li = [1,12,9,"age","alex"]# #列表表示为[]括起来# #列表用","分割每个元素# #列表中的元素可以是数字 ...

  10. jsmind实现思维导图,和echars 的tree图类似

    https://blog.csdn.net/qq_41619796/article/details/88552029