Codeforces Beta Round #7 C. Line (扩展欧几里德)
题目链接:http://codeforces.com/problemset/problem/7/C
给你一个直线方程,有整数解输出答案,否则输出-1。
扩欧模版题。这里有讲解:http://www.cnblogs.com/Recoder/p/5459812.html
(很久没写exgcd,都不会写了)
1 #include <bits/stdc++.h> 2 using namespace std; 3 typedef long long LL; 4 5 LL exgcd(LL a , LL b , LL &x , LL &y) { 6 LL res = a; 7 if(!b) { 8 x = 1 , y = 0; 9 } 10 else { 11 res = exgcd(b , a % b , x , y); 12 LL temp = x; 13 x = y; 14 y = temp - a / b * y; 15 } 16 return res; 17 } 18 19 int main() 20 { 21 LL a , b , c , gcd , x , y; 22 cin >> a >> b >> c; 23 gcd = exgcd(a , b , x , y); 24 if(c % gcd == 0) { 25 LL temp = -c / gcd; 26 cout << x * temp << " " << y * temp << endl; 27 } 28 else { 29 cout << -1 << endl; 30 } 31 }
转载于:https://www.cnblogs.com/Recoder/p/5459841.html
Codeforces Beta Round #7 C. Line (扩展欧几里德)相关推荐
- Codeforces Beta Round #7 C. Line 扩展欧几里德
C. Line time limit per test 1 second memory limit per test 256 megabytes input standard input output ...
- Codeforces Beta Round #7
Codeforces Beta Round #7 http://codeforces.com/contest/7 A 水题 1 #include<bits/stdc++.h> 2 usin ...
- Codeforces Beta Round #5 B. Center Alignment 模拟题
B. Center Alignment 题目连接: http://www.codeforces.com/contest/5/problem/B Description Almost every tex ...
- codeforces beta round 1
codeforces beta round 1 A Theatre Square in the capital city of Berland has a rectangular shape with ...
- Codeforces Beta Round #17 D. Notepad (数论 + 广义欧拉定理降幂)
Codeforces Beta Round #17 题目链接:点击我打开题目链接 大概题意: 给你 \(b\),\(n\),\(c\). 让你求:\((b)^{n-1}*(b-1)\%c\). \(2 ...
- Codeforces Beta Round #75 (Div. 1 Only) B. Queue 线段树。单点更新
http://codeforces.com/problemset/problem/91/B 题意: 给你n个数,求得i 到n中小于a[i]的最右边的a[j],然后求a[i]到a[j]之间包含了多少个数 ...
- Codeforces Beta Round #51 D. Beautiful numbers 数位dp + 状态优化
传送门 文章目录 题意: 思路: 题意: 思路: 数位dpdpdp挺经典的一个题辣,有一个很明显的状态就是f[pos][num][lcm]f[pos][num][lcm]f[pos][num][lcm ...
- Codeforces Beta Round #22 (Div. 2 Only) E. Scheme(DFS+强连通)
题目大意 给了 n(2<=n<=105) 个点,从每个点 u 出发连向了一个点 v(共 n 条边) 现在要求添加最少的边使得整个图是一个强连通图 做法分析 这道题千万不要一般化:先求强连通 ...
- Codeforces Beta Round #4 (Div. 2 Only)
Codeforces Beta Round #4 (Div. 2 Only) A 水题 1 #include<bits/stdc++.h> 2 using namespace std; 3 ...
最新文章
- 小程序webview不全屏_有赞微信商城和有赞微信小程序什么不一样
- 【Android学习笔记】设置App启动页
- ArrayList的实现原理--转
- linux raid卷,linux – Areca RAID卷和LVM对齐
- jQuery弹出框示例
- Jersey WebResource –标头不附加
- Windows services相关命令
- 简述计算机控制系统调试和运行的过程,简述计算机原理与系统启动过程
- error C2440: 'static_cast' : cannot convert from 'void (__thiscall CMainFrame::* )(void)' to ...
- 小丸工具箱\FFmpeg踩坑记录
- Python3 网络爬虫 <教程全集>
- 三星手机服务器暂时不可用是怎么回事,三星手机用户注意了!三星云将于2017年1月20日起停止服务...
- 编程之类的文案_精选50句文案,个个都是让你灵感喷涌的句子!
- 树莓派3B+安装Android 系统
- 微信服务器与客户端消息通讯机制,微信在部分地区发生连接故障,你遇到了么?...
- ADC模数转换器(STM32系列)
- 加油------加油
- powerdesigner设置 name to comment
- POJ3349-Snowflake Snow Snowflakes
- 学习笔记 - 用户故事(User Story)
热门文章
- 【Linux】一步一步学Linux——rmdir命令(22)
- 2022.2.13java学习笔记
- ansible(5)——使用通配符操作ansible命令
- Shell(7)——case
- hadoop(5)——mrjob的使用(1)——直接在本地测试
- 颜色分类—leetcode75
- oracle布尔true 1,将.NET布尔数据类型映射到实体框架中的oracle数(1,0)会抛出错误
- 32位有符号整数_[LeetCode] 8. 字符串转换整数 (atoi)
- Linux mysql设置密码
- ofstream写文件