题目

题意:

  给出 n,m,k ,让你在长为 n,宽为 m 的坐标系里构建一个三角形,使得面积= n*m/k。如果存在,输出“YES”,输出三角形三个顶点的坐标;  如果不存在,输出“NO”。

思路:

  参考其他人博客。 设长为a ,宽为b,所以要 a*b/2 = (n*m)/k ,要使有解,必须 2*n*m/k 是整数,所以只要讨论 2*n*m/k 就可。如果k=1,a<=n和b<=m范围内 一定  a*b/2 != n*m,所以 k >=2 。

  设g= gcd( 2*n, k ):

  如果g==1,则说明 2*n 不可能整除 k ,所以只能是2*m整除k ,这里可以得出a=n, b=2*m/k

  如果 2<= g <= k ,则可以设 a=2*n/g(因为g>=2,所以a<=n),b=m*g/k(因为g<=k,所以b<=m),就是答案。

 #include<iostream>
#include<cstdio>
#include <cctype>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<string>
#include<cmath>
#include<set>
#include<vector>
#include<stack>
#include<queue>
#include<map>
using namespace std;
#define ll long long
#define mem(a,x) memset(a,x,sizeof(a))
#define se second
#define fi first
const ll mod=1e9+;
const int INF= 0x3f3f3f3f;
const int N=3e5+; ll n,k,m; ll gcd(ll x,ll y)
{
return y==?x:gcd(y,x%y);
}
int main()
{
cin>>n>>m>>k;
if( (*m*n) %k!= || k<)
{
cout<<"NO"<<endl;
return ;
}
cout<<"YES"<<endl;
cout<<<<' '<<<<endl; ll a,b,g;
g=gcd(*n,k);
if(g==)
{
a=n; b=*m/k;
}
else
{
a=*n/g; b=m*g/k;
}
cout<<a<<' '<<<<endl;
cout<<<<' '<<b<<endl;
}

Codeforces Round #512 (Div. 2) D. Vasya and Triangle(几何+思维)的更多相关文章

  1. 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 ...

  2. 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的整数倍 ...

  3. 构造水题 Codeforces Round #206 (Div. 2) A. Vasya and Digital Root

    题目传送门 /* 构造水题:对于0的多个位数的NO,对于位数太大的在后面补0,在9×k的范围内的平均的原则 */ #include <cstdio> #include <algori ...

  4. Codeforces Round #556 (Div. 2) - C. Prefix Sum Primes(思维)

    Problem  Codeforces Round #556 (Div. 2) - D. Three Religions Time Limit: 1000 mSec Problem Descripti ...

  5. Codeforces Round #512 (Div. 2, based on Technocup 2019 Elimination Round 1) C. Vasya and Golden Ticket 【。。。】

    任意门:http://codeforces.com/contest/1058/problem/C C. Vasya and Golden Ticket time limit per test 1 se ...

  6. Codeforces Round #512 (Div. 2, based on Technocup 2019 Elimination Round 1) E. Vasya and Good Sequences(DP)

    题目链接:http://codeforces.com/contest/1058/problem/E 题意:给出 n 个数,对于一个选定的区间,区间内的数可以通过重新排列二进制数的位置得到一个新的数,问 ...

  7. Codeforces Round #512 (Div. 2, based on Technocup 2019 Elimination Round 1) E. Vasya and Good Sequences

    题目链接 官网题解写的好清楚,和昨晚Aguin说的一模一样…… 这题只和每个数1的个数有关,设每个数1的个数的数组为$b$,就是首先一段如果是好的,要满足两个条件: 1.这一段$b$数组和为偶数,因为 ...

  8. Codeforces Round #322 (Div. 2) A. Vasya the Hipster 水题

    A. Vasya the Hipster Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/581/p ...

  9. Codeforces Codeforces Round #319 (Div. 2) C. Vasya and Petya's Game 数学

    C. Vasya and Petya's Game Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/ ...

随机推荐

  1. js判断图片加载完成

    <!DOCTYPE> <html> <head> <meta http-equiv="Content-Type" content=&quo ...

  2. css 颜色混合模式 mix-blend-mode

    CSS3 新增了一个很有意思的属性 -- mix-blend-mode ,其中 mix 和 blend 的中文意译均为混合,那么这个属性的作用直译过来就是混合混合模式,当然,我们我们通常称之为混合模式 ...

  3. SELinux安全子系统的学习

    SELinux(Security-Enhanced Linux)是美国国家安全局在 Linux 开源社区的帮助下开发的 一个强制访问控制(MAC,Mandatory Access Control)的安 ...

  4. mysql备份时过滤掉某些库 以及 去掉"Warning: Using a password on the command line interface can be insecure."提示信息

    在对mysql进行完整备份时使用--all-database参数 # mysqldump -u root -h localhost -p --all-database > /root/all.s ...

  5. mysql 基本操作及对用户操作

    1.登录/退出基本操作            登录:mysql [-h服务器地址] -u登录名 -P端口号 -p             或登录:mysql [--host=服务器地址] --user ...

  6. [CF1005F]Berland and the Shortest Paths_最短路树_堆优化dij

    Berland and the Shortest Paths 题目链接:https://www.codeforces.com/contest/1005/problem/F 数据范围:略. 题解: 太鬼 ...

  7. ILSVRC比赛带来的算法

    李飞飞和它的团队搜集了ImageNet一个超过15 million的图像数据集,大约有22,000类.这个文件集合对深度卷积网络极大地推进深度学习各领域的发展. ILSVRC是对ImageNet进行分 ...

  8. WEB学习路线2019完整版(附视频教程+网盘下载地址)

    WEB学习路线2019完整版(附视频教程+网盘下载地址).适合初学者的最新WEB前端学习路线汇总! 在当下来说web前端开发工程师可谓是高福利.高薪水的职业了.所以现在学习web前端开发的技术人员也是 ...

  9. 翻译-在10行代码之内创建容器化的.net core应用

    本文翻译自Hans Kilian的文章 Creating a containerized .NET core application in less than 10 lines of code htt ...

  10. 基于【 责任链模式】二 || 网关zuul过滤器封装

    一.基于责任链模式封装网关拦截 上一篇文章中已经使用建造者模式对网关拦截进行封装,存在一个问题,在连接器build中,每一个拦截都要进行true判断,代码看起来冗余,下面使用责任链模式封装 1.基于责 ...