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* ...
随机推荐
- 让我来教你如何免费使用RHEL小红帽系统
RHEL安装注册过程中遇到的问题 从开始注册到正常使用 如何获取正版RHEL 注意事项 VMware虚拟机下载安装 安装中出现的问题 从开始注册到正常使用 答主是个动手能力比较强的人 ,所以当老师讲到 ...
- Java第三十天,I/O操作
一.基本概念 输入输出一般是相对与内存.CPU寄存器.当前进程来说的 输入:从硬盘.键盘等外部设备读取数据到内存.当前进程或CPU寄存器中 输出:利用当前进程将数据写入到硬盘.终端显示屏等外部设备中 ...
- 2017蓝桥杯杨辉三角(C++C组)
题目: 杨辉三角也叫帕斯卡三角,在很多数量关系中可以看到,十分重要.第0行: 1第1行: 1 1第2行: 1 2 1第3行: 1 3 ...
- VM卸载不完全,重装的一个下午
玩软件就是随时面临着重新来过的危险.今天一不小心就把VM给高爆了,爆的很高的那种. 卸载不完全的VM如何在不重装系统的情况下安装. 首先第一步,肯定是通过控制面板去卸载VM,但是....但是...我靠 ...
- Go语言 可变参数
最近与同事讨论时,提到Go语言的可变参数,之前没有总结过相关知识点,今天我们介绍一下Go语言的可变参数. 可变参数(Variable Parameters):参数数量可变的函数称之为可变参数函数,主要 ...
- Django 表单处理流程
Django 的表单处理:视图获取请求,执行所需的任何操作,包括从模型中读取数据,然后生成并返回HTML页面(从模板中),我们传递一个包含要显示的数据的上下文.使事情变得更复杂的是,服务器还需要能够处 ...
- Silverlight 2.5D RPG游戏技巧与特效处理:(十一)AI系统
Silverlight 2.5D RPG游戏技巧与特效处理:(十一)AI系统 作者: 深蓝色右手 来源: 博客园 发布时间: 2011-04-19 11:18 阅读: 1282 次 推荐: 0 ...
- 将class 编译后文件内容输入到 文本文件中的命令
javap -c InnerTest$1 > InnerTest$1.txt
- MD5中使用16进制
MD5中使用16进制消息摘要 分类: java_secruity2012-12-28 13:11 719人阅读 评论(0) 收藏 举报 消息摘要 由于数据在计算机中的表示,最终以二进制的形式存在,所以 ...
- Centos7_搭建暗网网站
Tor运行原理 请求方需要使用:洋葱浏览器(Tor Browser)来对暗网网站进行访问 响应放需要使用:Tor协议的的Hidden_service 搭建步骤 更新YUM源: rpm -Uvh htt ...