2018.09.23 codeforces 1053A. In Search of an Easy Problem(gcd)
传送门
今天的签到题。
有一个很显然的结论,gcd(n∗m,k)≤2gcd(n*m,k)\le 2gcd(n∗m,k)≤2。
本蒟蒻是用的行列式求三角形面积证明的。
如果满足这个条件,就可以直接构造出一个满足限制的直角三角形了。
代码:
#include<bits/stdc++.h>
#define ll long long
using namespace std;
inline ll read(){
ll ans=0;
char ch=getchar();
while(!isdigit(ch))ch=getchar();
while(isdigit(ch))ans=(ans<<3)+(ans<<1)+(ch^48),ch=getchar();
return ans;
}
ll n,m,k;
inline ll gcd(ll a,ll b){while(b){ll t=a;a=b,b=t%a;}return a;}
int main(){
n=read(),m=read(),k=read();
ll g=gcd(n,k),ttmp,f=-1;
n/=g,k/=g;
if(g!=1)f=1,ttmp=g;
g=gcd(m,k);
m/=g,k/=g;
if(g!=1)f=2,ttmp=g;
if(k>2){puts("NO");return 0;}
puts("YES");
if(k==1){
if(f==1)n*=2;
else m*=2;
}
printf("0 0\n%I64d 0\n0 %I64d",n,m);
return 0;
}
2018.09.23 codeforces 1053A. In Search of an Easy Problem(gcd)的更多相关文章
- codeforces A. In Search of an Easy Problem
A. In Search of an Easy Problem time limit per test 1 second memory limit per test 256 megabytes inp ...
- 2018.09.23 codeforces 1053B. Vasya and Good Sequences(前缀和)
传送门 考试的时候卡了一会儿. 显然这个答案只跟二进制位为1的数量有关. 还有一个显然的结论. 对于一个区间[l,r][l,r][l,r],如果其中单个数二进制位为1的数量最大值不到区间所有数二进制位 ...
- CodeForces - 1058A. In Search of an Easy Problem
这题,全零是esay有1是hard,真难呀. #include<bits/stdc++.h> using namespace std; int main(){ int n,i,x,flag ...
- Codeforces Round #367 (Div. 2) C. Hard problem(DP)
Hard problem 题目链接: http://codeforces.com/contest/706/problem/C Description Vasiliy is fond of solvin ...
- codeforces#1157D. Ehab and the Expected XOR Problem(构造)
题目链接: http://codeforces.com/contest/1174/problem/D 题意: 构造一个序列,满足以下条件 他的所有子段的异或值不等于$x$ $1 \le a_i< ...
- The 2018 ACM-ICPC Asia Qingdao Regional Contest, Online -C:Halting Problem(模拟)
C Halting Problem In computability theory, the halting problem is the problem of determining, from a ...
- 【LeetCode】95. Unique Binary Search Trees II 解题报告(Python)
[LeetCode]95. Unique Binary Search Trees II 解题报告(Python) 标签(空格分隔): LeetCode 作者: 负雪明烛 id: fuxuemingzh ...
- C#/AutoCAD 2018/ObjectArx/二次开发添加圆对象的的例子(五)
C#/AutoCAD 2018/ObjectArx/二次开发添加圆对象的的例子(五) 1.创建一个图形对象的步骤如下见上一篇博客(三)2.添加删除实体的工具函数见上一篇博客(四) 3.添加圆的例子(完 ...
- Leetcode35 Search Insert Position 解题思路(python)
本人编程小白,如果有写的不对.或者能更完善的地方请个位批评指正! 这个是leetcode的第35题,这道题的tag是数组,python里面叫list,需要用到二分搜索法 35. Search Inse ...
随机推荐
- ABAP-TXT文件上传
at selection-screen on value-request for pc_file. call function 'WS_FILENAME_GET' exporting ...
- Java使用poi从数据库读取数据生成Excel表格
想要使用POI操作以xsl结尾的Excel,首先要下载poi相关的jar包,用到的jar有: poi-3.9.jar poi-ooxml-3.9.jar poi-ooxml-schemas-3.9.j ...
- C# 事件 event 【转】
C#事件(event)解析 事件(event),这个词儿对于初学者来说,往往总是显得有些神秘,不易弄懂.而这些东西却往往又是编程中常用且非常重要的东西.大家都知道windows消息处理机制的重要, ...
- python面试题(转)
下面的代码输出什么? list = ['a', 'b', 'c', 'd', 'e'] print list[10:] 上面的代码输出[],并且不会导致IndexError错误 跟你想的一样,当取列表 ...
- Appium客户端,命令行启动server
目标:通过命令行启动Appium的server 1.通过命令行安装的Appium 直接命令行输入appium即可启动服务 2.安装的Appium客户端 可以查看客户端中打印的启动日志: ...
- count++线程安全与 synchronized对性能影响的测试
一个计时器,同时开启100个线程,每个线程休眠1ms钟后,将全局静态变量count加1,这100个线程创建完之后,休眠500ms,计算总耗时,程序如下: public class Counter { ...
- 配置Tomcat 7 Gzip
<Connector URIEncoding="UTF-8" connectionTimeout="20000" port="8080" ...
- 关于number...的精度问题
一 当数字的精度被定为number(3,2)时, 这时他能输入的数字整数部分只能是3-2=1位, 小数位如果不够会用0补齐, 超出的四舍五入保留3位小数. SQL> insert into t_ ...
- 134. Gas Station (Array; DP)
There are N gas stations along a circular route, where the amount of gas at station i is gas[i]. You ...
- PAT L2-008 最长对称子串(模拟字符串)
对给定的字符串,本题要求你输出最长对称子串的长度.例如,给定Is PAT&TAP symmetric?,最长对称子串为s PAT&TAP s,于是你应该输出11. 输入格式: 输入在一 ...