codeforces 17C C. Line(exgcd解不定方程)
2015-08-24 12:00
489 查看
题目链接:
codeforces 17C题目大意:
解Ax+By+C = 0题目分析:
拓展欧几里得解不定方程模板题AC代码:
#include <iostream> #include <cstdio> #include <algorithm> #include <cstring> using namespace std; typedef long long LL; LL exgcd ( LL a , LL b , LL &x , LL &y ) { if ( b == 0 ) { x = 1; y = 0; return a; } LL r = exgcd ( b , a%b , x , y ); LL t = x; x = y; y = t - a/b*y; return r; } LL a,b,c,x,y; int main ( ) { while ( ~scanf ( "%lld%lld%lld" , &a , &b , &c ) ) { c = -c; LL r = exgcd ( a , b , x , y ); if ( c%r ) puts ( "-1" ); else { x *= c/r; y *= c/r; printf ( "%I64d %I64d\n" , x , y ); } } }
相关文章推荐
- POJ 1125 Stockbroker Grapevine 最短路 难度:0
- SQL Server2008执行脚本
- Java-正则表达式的学习
- Rectangle Bin Packing
- python glob.glob使用
- oracle 索引的(创建、简介、技巧、怎样查看)
- java代码实现如jsp页面的form请求方式一HttpURLConnection请求
- Maven学习笔记(一)——Maven简介、下载与安装
- 黑马程序员--OC之匿名对象问题
- Java中Process类的使用与注意事项
- koa-router 路由优先级问题
- sql server创建存储过程(有参,无参,有输出)
- 判断浏览器是否是IE
- POJ 2253 Frogger 最短路 难度:0
- SCI/EI/ISTP检索、收录查询
- Python操作MySQL
- JNI学习4——访问数组(JNI)
- vasp 编译
- 上传文件
- linux动态库路径配置