前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >CodeForces - 1058D D. Vasya and Triangle

CodeForces - 1058D D. Vasya and Triangle

作者头像
风骨散人Chiam
发布2020-10-28 10:37:52
4080
发布2020-10-28 10:37:52
举报
文章被收录于专栏:CSDN旧文

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.

在这里插入图片描述
在这里插入图片描述

不要被他给的图迷惑,这就是个水题。

代码语言:javascript
复制
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;
      }
  }
}
本文参与 腾讯云自媒体同步曝光计划,分享自作者个人站点/博客。
原始发表:2019/05/23 ,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体同步曝光计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档