CodeForces - 1058D D. Vasya and Triangle
D. Vasya and Triangle
time limit per test1 second
memory limit per test256 megabytes
inputstandard input
outputstandard output
Vasya has got three integers n, m and k. He’d like to find three integer points (x1,y1), (x2,y2), (x3,y3), such that 0≤x1,x2,x3≤n, 0≤y1,y2,y3≤m and the area of the triangle formed by these points is equal to nmk.
Help Vasya! Find such points (if it’s possible). If there are multiple solutions, print any of them.
Input
The single line contains three integers n, m, k (1≤n,m≤109, 2≤k≤109).
Output
If there are no such points, print “NO”.
Otherwise print “YES” in the first line. The next three lines should contain integers xi,yi — coordinates of the points, one point per line. If there are multiple solutions, print any of them.
You can print each letter in any case (upper or lower).
Examples
inputCopy
4 3 3
outputCopy
YES
1 0
2 3
4 1
inputCopy
4 4 7
outputCopy
NO
Note
In the first example area of the triangle should be equal to nmk=4. The triangle mentioned in the output is pictured below:
In the second example there is no triangle with area n*m/k=16/7.
不要被他给的图迷惑,这就是个水题。
include<iostream>
using namespace std;
int main()
{
long long int n,m,k,i;
cin>>n>>m>>k;
if((n*m)%(2*k)!=0)
{
cout<<"NO";
return 0;
}
for(i=1;i<=m;i++)
{
if((n*i)==(2*n*m)/k)
{
cout<<"YES"<<endl;
cout<<0<<' '<<0<<endl;
cout<<0<<' '<<n<<endl;
cout<<n<<' '<<i<<endl;
return 0;
}
}
for(i=1;i<=n;i++)
{
if((m*i)==(2*n*m)/k)
{
cout<<"YES"<<endl;
cout<<0<<' '<<0<<endl;
cout<<0<<' '<<m<<endl;
cout<<0<<' '<<i<<endl;
return 0;
}
}
}
CodeForces - 1058D D. Vasya and Triangle的更多相关文章
- Codeforces 1058 D. Vasya and Triangle 分解因子
传送门:http://codeforces.com/contest/1058/problem/D 题意: 在一个n*m的格点中,问能否找到三个点,使得这三个点围成的三角形面积是矩形的1/k. 思路: ...
- Codeforces 1058 D. Vasya and Triangle(分解因子)
题目:http://codeforces.com/contest/1058/problem/D 题意:有一个大小为N*M的矩阵内,构造一个三角形,使面积为(n*m)/k.若存在输出三个顶点(整数). ...
- 【Codeforces 1030D】Vasya and Triangle
[链接] 我是链接,点我呀:) [题意] 题意 [题解] 参考这篇题解:https://blog.csdn.net/mitsuha_/article/details/82825862 为什么可以保证m ...
- Codeforces Round #512 D - Vasya and Triangle
D - Vasya and Triangle #include<bits/stdc++.h> using namespace std; #define LL long long LL gc ...
- codeforces 1058D.Vasya and Triangle (gcd)
<题目链接> <转载于 >>> > 题目大意: 给出n.m.k.求一个三角形使它的面积等于n*m/k 并且这个三角形的三个顶点所在的坐标为整数点,且顶点满 ...
- Codeforces Round #512 (Div. 2) D. Vasya and Triangle
参考了别人的思路:https://blog.csdn.net/qq_41608020/article/details/82827632 http://www.cnblogs.com/qywhy/p/9 ...
- Codeforces Round #512 (Div. 2) D.Vasya and Triangle 数学
题面 题意:给你n,m,k,在你在(0,0)到(n,m)的矩形内,选3个格点(x,y都是整数),使得三角形面积为n*m/k,不能找到则输出-1 题解:由毕克定理知道,格点多边形的面积必为1/2的整数倍 ...
- Codeforces Round #512 (Div. 2) D. Vasya and Triangle(几何+思维)
题目 题意: 给出 n,m,k ,让你在长为 n,宽为 m 的坐标系里构建一个三角形,使得面积= n*m/k.如果存在,输出“YES”,输出三角形三个顶点的坐标: 如果不存在,输出“NO”. 思路: ...
- codeforces 1030D Vasya and Triangle【思维+gcd】
题目:戳这里 题意:选出三个点构成三角形,要求面积为n*m/k. 解题思路:因为三个点的坐标都是正整数,根据三角形面积公式(x1*(y2-y3)+x2*(y3-y1)+x3*(y1-y2))/2=n* ...
随机推荐
- android开发对应高德地图定位服务进度一
进行android的高德地图开发首先需要进入高德地图的控制台进行注册登录.之后创建新的应用并且绑定软件得到相应的key. 这里面需要找到自己软件对应的多个SHA1.这里有发布版和调试版,以及对应的软件 ...
- 家庭版记账本app开发完成
经过这几天关于android的相关学习,对于家庭版记账本app以及开发结束. 实现的功能为:用户的注册.登录.添加支出账单.添加收入账单.显示所有的该用户的账单情况(收入和支出).生产图表(直观的显示 ...
- Linux网络安全篇,认识防火墙(三),TCP Wrappers
1.防火墙设置文件 任何以xinetd管理的服务都可以通过 /etc/hosts.allow /etc/hosts.deny 这两个文件来设置防火墙(针对源IP或域进行允许或操作的设置). 其实/et ...
- django 利用ORM对单表进行增删改查
牛小妹上周末,一直在尝试如何把数据库的数据弄到界面上.毕竟是新手,搞不出来,文档也看不懂.不过没关系,才刚上大学.今晚我们就来解释下,要把数据搞到界面的第一步.先把数据放到库里,然后再把数据从库里拿出 ...
- hadoop(七)集群配置同步(hadoop完全分布式四)|9
前置配置:rsync远程同步|xsync集群分发(hadoop完全分布式准备三)|9 1. 分布式集群分配原则 部署分配原则 说明Namenode和secondarynamenode占用内存较大,建议 ...
- 彻底卸载----LoadRunner
保证所有LoadRunner的相关进程(包括Controller.VuGen.Analysis和Agent Process)全部关闭: 备份好LoadRunner安装目录下测试脚本,这些脚本一般存放在 ...
- xftp连接centos7
1.下载xftp文件,并正常进行安装 2.安装好之后运行,并新建会话,此时可见如下界面: 注意: 名称,可随便输入,自己能看懂是什么就行 主机,输入当前Linux服务器的ip(如何获取服务器 ...
- vue 全局自定义组件
1.vue文件 <template> <div style="position: absolute;bottom: 10px;text-align: center;widt ...
- Jmeter连接mysql数据库?so easy!!!
一.确保mysql数据库能够通过Navicat等远程连接工具连接. 注意:一定是确保能使用navicat连接,而不是dos窗口! 比如笔者需要查询ecshop数据库下的ecs_admin_user表, ...
- PHP-fpm 远程代码执行漏洞(CVE-2019-11043)复现
简介 9 月 26 日,PHP 官方发布漏洞通告,其中指出:使用 Nginx + php-fpm 的服务器,在部分配置下,存在远程代码执行漏洞.并且该配置已被广泛使用,危害较大. 漏洞概述 Nginx ...