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

分析:本题最重要的是在给出的直线是不是平行于坐标轴,即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. Node.js:GET/POST请求

    ylbtech-Node.js:GET/POST请求 1.返回顶部 1. Node.js GET/POST请求 在很多场景中,我们的服务器都需要跟用户的浏览器打交道,如表单提交. 表单提交到服务器一般 ...

  2. spy++ 句柄消息详解

    使用spy++捕获到的消息详解 主要是今天正好自己用到. 原来也有用过SPY++查看消息,然后自己SendMessage或者PostMessage 直接发送消息给目标程序.但是原来一用就有效果,今天要 ...

  3. Elasticsearch之cur查询索引

    前提, Elasticsearch之curl创建索引库 Elasticsearch之curl创建索引 Elasticsearch之curl创建索引库和索引时注意事项 Elasticsearch之cur ...

  4. C#缓存

    最近在学习缓存的知识,博客园中的 缓存资料 觉得信息不错值得学习

  5. Core篇——初探IdentityServer4(客户端模式,密码模式)

    Core篇——初探IdentityServer4(客户端模式,密码模式) 目录 1.Oatuth2协议的客户端模式介绍2.IdentityServer4客户端模式实现3.Oatuth2协议的密码模式介 ...

  6. Codeforces Round #455

    Generate Login 第二个单词肯定只取首字母 Solution Segments 从1开始的线段和在n结束的线段各自凑一凑,剩下的转化为规模为n-2的子问题. Solution Python ...

  7. Linux强行踢用户

    首先who执行查看有几个终端在链接使用系统.如要踢出tty2 方法1: pkill -9 -t tty2 方法2: fuser -k /dev/tty2 fuser 指令 用途 使用文件或文件结构识别 ...

  8. 【WebApp】IOS兼容问题

    最近,主要是基于Framework7 + RequireJs框架,移动端团队开发Webview框架,内嵌Web的模式进行WebApp开发. 在开发过程中不得不遇到一些 兼容性问题. 1.现象:IOS环 ...

  9. 团体程序设计天梯赛-练习集-L1-024. 后天

    L1-024. 后天 如果今天是星期三,后天就是星期五:如果今天是星期六,后天就是星期一.我们用数字1到7对应星期一到星期日.给定某一天,请你输出那天的“后天”是星期几. 输入格式: 输入第一行给出一 ...

  10. Python笔记15------图像

    主要三个库:Pilow(PIL).OpenCV.Skimage(针对scipy,用的少) 小例子:给一张图片的左上角粘贴一个相同的图片(缩略并旋转了45度) from PIL import Image ...