Codeforces Round #451 (Div. 2)
来源:互联网 发布:c语言vc6.0软件下载 编辑:程序博客网 时间:2024/06/03 12:00
题意:
解个二元一次方程,要正整数解。
#include <iostream>#include <string>#include <string.h>#include <math.h>#include <vector>#include <map>using namespace std;typedef long long lint;lint ex_gcd(lint a, lint b, lint& x, lint& y){if(b == 0){x = 1;y = 0;return a;}lint r = ex_gcd(b, a % b, x, y);lint t = x;x = y;y = t - a / b * y;return r;}bool check(lint a, lint b, lint c, lint& x, lint& y){lint r = ex_gcd(a, b, x, y);if(c % r){return false;}a /= r; b /= r; c /= r;x *= c;x = ((x % b) + b ) % b;y = (c - a * x) / b;return y >= 0;}int main(){lint c,a,b;cin>>c>>a>>b;lint x, y;if(check(a, b, c, x, y)){printf("YES\n%lld %lld\n", x, y);}else{printf("NO\n");}}
阅读全文
0 0
- Codeforces Round #451 (Div. 2)
- Codeforces Round #451 (Div. 2)
- Codeforces Round #451 (Div. 2)
- Codeforces Round #451 (Div. 2)
- Codeforces Round #451 (Div. 2)
- Codeforces Round #451 (Div. 2)
- Codeforces Round #451 (Div. 2)
- Codeforces Round #451 (Div. 2)
- Codeforces Round #451 (Div. 2) A. Rounding
- codeforces Round #451 (Div. 2) Phone Numbers
- Codeforces Round #451 (Div. 2) a
- Codeforces Round #451 (Div. 2) A-B
- Codeforces Round #451 (Div. 2)题解
- Codeforces Round #451 (Div. 2) C
- Codeforces Round #451 (Div. 2) E
- Codeforces Round #451 (Div. 2) D
- Codeforces Round #451 (Div. 2) C
- Codeforces Round #451 (Div. 2) B
- 高晓松 鱼羊野史(全六卷)(ED2000.COM).epub 免费下载
- Lighttpd源码分析之状态机与插件
- JAVA 向数据库中插入数据并获取主键的方法(逐渐补充)
- python重命名
- Python微型web开发框架flask介绍及一个小例子
- Codeforces Round #451 (Div. 2)
- MySQL基础教程11-Mysql删除数据表操作
- 高效并发处理之libevent
- [爱与性的实验报告(修订本)].小庄.扫描版(ED2000.COM).pdf 免费下载
- 蓝桥杯 算法提高 周期字串
- Python(5)————函数闭包方法
- Integer关于equals与==的比较(自动拆装箱技术和常量池技术)
- Ubuntu下学习git第一天--安装、创建仓库、添加文件
- Java Web目前主流的框架以及正在兴起的框架