UVA - 10673 Play with Floor and Ceil
来源:互联网 发布:五阿哥知画圆房片段 编辑:程序博客网 时间:2024/06/10 00:02
题意:LRJ线性方程的题目,但这道题的特殊在于一定有整数解,因为如果floor(x/k) == ceil(x/k)的话,那么x一定是最大公约数的倍数,如果不相等的话,那么最多相差1,最大公约数是1,同样满足条件,所以一定成立,照着书来就行了
#include <iostream>#include <cstdio>#include <cstring>#include <cmath>using namespace std;void gcd(long long a,long long b,long long &d,long long &x,long long &y){ if (!b) d = a,x = 1,y = 0; else { gcd(b,a%b,d,y,x); y -= x*(a/b); }}int main(){ int t; scanf("%d",&t); while (t--){ long long a,b,c,d,k,x,y; scanf("%lld%lld",&c,&k); a = floor(1.0*c/k); b = ceil(1.0*c/k); gcd(a,b,d,x,y); x *= c/d; y *= c/d; printf("%lld %lld\n",x,y); } return 0;}
- uva 10673 - Play with Floor and Ceil
- UVA 10673 Play with Floor and Ceil
- UVa 10673 - Play with Floor and Ceil
- uva 10673 - Play with Floor and Ceil
- UVA 10673 Play with Floor and Ceil
- UVA - 10673 Play with Floor and Ceil
- UVA 10673 Play with Floor and Ceil
- UVa:10673 Play with Floor and Ceil
- UVa 10673 - Play with Floor and Ceil
- Play with Floor and Ceil - UVa 10673
- UVA - 10673 Play with Floor and Ceil
- UVA 10673 Play with Floor and Ceil
- uva 10673 Play with Floor and Ceil(简单数论)
- UVa 10673 Play with Floor and Ceil (数论)
- uva 10673 - Play with Floor and Ceil(欧几里得)
- uva 10673 - Play with Floor and Ceil(欧几里得算法)
- UVA 10673 Play with Floor and Ceil (扩展欧几里得算法)
- UVa 10673 - Play with Floor and Ceil (扩展欧几里得)
- 142day:LCD驱动1
- 使用dom4j和使用Element.selectSingleNode出错解决
- svn如何安装,svn如何配置,svn安装配置
- js计算字符串长度,其中中文是utf8格式的
- JAVA基础:将数据库操作封装
- UVA - 10673 Play with Floor and Ceil
- TCP/UDP端口列表
- Remove Duplicates from Sorted Array 有序数组删除重复元素 @LeetCode
- Android:异步任务(AsyncTask)
- 纪念第一篇
- 27-python_GUI-布局管理-事件处理
- 统计
- 左天才,右疯子
- 如何选择商铺投资