题目

题意:

  给出 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. 关于css清除元素浮动的方法总结(overflow clear floatfix)

    在前两天的一个面试中考官问我web中清除浮动的一些css常用方法,我很轻松的答出了: 1.overflow:hidden 2.clear:both 3.floatfix类 然后问题就来了,考官接着问' ...

  2. xadmin自定义菜单、增加功能、富文本编辑器

    xadmin功能:https://www.cnblogs.com/derek1184405959/p/8682250.html#blogTitle7

  3. 用Python打开文件夹

    用Python读取文件夹, 然后打开文件 下面读取到文件的每一个内容, 然后加上路径 import os path = r'../Downloads/text/content' for filenam ...

  4. Linux_高级用法

    LInux如何压缩和解压文件 文件压缩与解压主要讲zip和tar 安静模式和文件夹 zip -r -q -o test.zip 需要打包文件 查看打包文件 du -h test.zip 上节学过的fi ...

  5. 阿里云 maven仓库地址配置

    1. maven 配置文件配置settings.xml中设置mirror节点 <mirror> <id>nexus-aliyun</id> <mirrorOf ...

  6. sem_wait sem_post信号量操作进本函数

    sem_wait   sem_post 信号量的数据类型为结构sem_t,它本质上是一个长整型的数.函数sem_init()用来初始化一个信号量.它的原型为: extern int sem_init ...

  7. 使用gomod后,导入模块与编译要注意的事项

    问题:在使用go mod后,执行编译会报错: Cannot load xxx: cannot find module providing package xxx 目录结构如下: J:. │ └─src ...

  8. linux服务器搭建lnmp php 微擎环境备用

    以前的时候装个php环境各种的配置麻烦啊,于是乎我就像搜搜一键安装php环境,果然 lamp 和phpstudy 两个环境软件都支持,最后发现lamp 还合胃口就选择了lamp https://lnm ...

  9. Python-02-基础知识

    一.第一个Python程序 [第一步]新建一个hello.txt [第二步]将后缀名txt改为py [第三步]使用记事本编辑该文件 [第四步]在cmd中运行该文件 print("Hello ...

  10. python 之 并发编程(非阻塞IO模型、I/O多路复用、socketserver的使用)

    9.16 非阻塞IO模型 cpu占用率过高 服务端: from socket import * import time s = socket() s.bind(('127.0.0.1',8080)) ...