题目

题意:

  给出 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. Eureka客户端源码流程梳理

    前面梳理了Eureka服务端的流程,现在整理下客户端的流程. 1.在这个包(spring-cloud-netflix-eureka-client)里面寻找客户端启动入口相关配置,关键配置文件sprin ...

  2. 《Netty实战》源码运行及本地环境搭建

     1.源码路径: GitHub - zzzvvvxxxd/netty-in-action-cn: Netty In Action 中文版 ,中文唯一正版<Netty实战>的代码清单 下载后 ...

  3. 教你使用Webpack搭建环境 TypeScript (2)

      一. 环境搭建1.1. TypeScript环境安装已经配置好的环境,大家可以直接下载:https://github.com/coderwhy/HYLearnTS.git在上一个章节中我们说过,T ...

  4. Beginning Linux Programming 学习--chapter 11 Processes and Signals

     What's process--什么是进程? The UNIX standards, specifically IEEE Std 1003.1, 2004 Edition, defines a pr ...

  5. HTTP权威指南-概述

    URI 统一资源标识符 类似于邮件地址,邮箱. URL 统一资源定位符 URN 统一资源名 HTTP方法 get post put delete post head 状态码 200 OK 302 重定 ...

  6. LeetCode 442. 数组中重复的数据(Find All Duplicates in an Array) 17

    442. 数组中重复的数据 442. Find All Duplicates in an Array 题目描述 Given an array of integers, 1 ≤ a[i] ≤ n (n ...

  7. Java基础笔试练习(六)

    1.在Java中,一个类可同时定义许多同名的方法,这些方法的形式参数个数.类型或顺序各不相同,传回的值也可以不相同.这种面向对象程序的特性称为? A.隐藏 B.覆盖 C.重载 D.Java不支持此特性 ...

  8. AVL排序二叉树树

    AVL树第一部分,(插入) AVL树是一种自平衡二叉搜索树(BST),其中对于所有节点,左右子树的高度差不能超过1. 一个AVL树的示例 上面的树是AVL树,因为每个节点的左子树和右子树的高度之间的差 ...

  9. QT 设置程序图标

    1.应用窗口左上角的图标.状态栏上显示的图标用setWindowIcon()函数: 2.可执行程序的图标设置: (1).右键项目添加一个资源文件 (2).导入.ico文件图标

  10. ORA-01618 ORA-19809: limit exceeded for recovery files

    由于DB_RECOVERY_FILE_DEST_SIZE 参数设置太小,导致redo只能创建一组,无法创建节点二的日志组,节点二数据库无法启动,如下图: 修改参数后,节点二无法启动到mount模式,无 ...