题目:http://codeforces.com/contest/1058/problem/D

题意:有一个大小为N*M的矩阵内,构造一个三角形,使面积为(n*m)/k。若存在输出三个顶点(整数)。

分析:

首先可以判断,若(2*n*m)%k!=0,一定为NO。

其次,可以想到,三角形可以构造为一个顶点为(0,0)的直角三角形。且满足等式  (2*n*m)%k==0

如果k是偶数,那个k肯定可以和2约分,所以把k除2. 再得到tmp=gcd(n,k),x=n/tmp,就是说能用n约掉一部分k就约掉,再用k/=tmp,y=m/k;

如果k是奇数,等式左边的2不能约掉,就要在经过和上面相同的操作后,把a * 2或者把b*2,肯定是有一个满足不超过限制的,因为之前a或b一定除了一个大于2的数。

 #include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll gcd(ll x,ll y){
if (y==) return x;
else return gcd(y,x%y);
}
int main(){
ll n,m,k; cin >> n >> m >> k;
if (*n*m%k) return cout << "NO\n",;
int f=;
if (k%==) k/=; else f=;
ll tmp=gcd(n,k);
ll x=n/tmp; k/=tmp; ll y=m/k;
if (f){
if (x*<n) x*=; else y*=;
}
cout << "YES\n";
cout << << " " << << endl;
cout << x << " " << << endl;
cout << << " " << y << endl;
return ;
}

Codeforces 1058 D. Vasya and Triangle(分解因子)的更多相关文章

  1. Codeforces 1058 D. Vasya and Triangle 分解因子

    传送门:http://codeforces.com/contest/1058/problem/D 题意: 在一个n*m的格点中,问能否找到三个点,使得这三个点围成的三角形面积是矩形的1/k. 思路: ...

  2. CodeForces - 1058D D. Vasya and Triangle

    D. Vasya and Triangle time limit per test1 second memory limit per test256 megabytes inputstandard i ...

  3. 【Codeforces 1030D】Vasya and Triangle

    [链接] 我是链接,点我呀:) [题意] 题意 [题解] 参考这篇题解:https://blog.csdn.net/mitsuha_/article/details/82825862 为什么可以保证m ...

  4. Codeforces Round #512 D - Vasya and Triangle

    D - Vasya and Triangle #include<bits/stdc++.h> using namespace std; #define LL long long LL gc ...

  5. uva 993 Product of digits (贪心 + 分解因子)

      Product of digits  For a given non-negative integer number N , find the minimal natural Q such tha ...

  6. D. Almost All Divisors(数学分解因子)

    其实这题并不难啊,但是分解因子的细节一定要小心. \(比如样例48,2是因子说明24也是因子,也就是说假如x存在\) \(那么x一定是因子中的最小数乘上最大数\) \(那我们现在去验证x是否存在,先拿 ...

  7. Codeforces 757B:Bash's Big Day(分解因子+Hash)

    http://codeforces.com/problemset/problem/757/B 题意:给出n个数,求一个最大的集合并且这个集合中的元素gcd的结果不等于1. 思路:一开始把素数表打出来, ...

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

  9. Codeforces 757B - Bash's Big Day(分解因子+hashing)

    757B - Bash's Big Day 思路:筛法.将所有因子个数求出,答案就是最大的因子个数,注意全为1的特殊情况. 代码: #include<bits/stdc++.h> usin ...

随机推荐

  1. oracle count 大表

    刚从生产环境导了一个大表到测试环境,迫不及待的要好好玩弄一下. 1.coun(1) ) from table_name; 条数: 567979280 时间:4:47 2.count 索引字段 sele ...

  2. my.ini优化mysql数据库性能的十个参数(推荐)

    (1).max_connections:允许的同时客户的数量.增加该值增加 mysqld 要求的文件描述符的数量.这个数字应该增加,否则,你将经常看到 too many connections 错误. ...

  3. 2018.06.27 POJ3281 Dining(最大流)

    Dining Time Limit: 2000MS Memory Limit: 65536K Total Submissions: 21578 Accepted: 9545 Description C ...

  4. Servlet中(Session、cookies、servletcontext)的基本用法

    /req: 用于获得客户端(浏览器)的信息 //res: 用于向客户端(浏览器)返回信息 1.session的设置:            //得到和req相关联的session,如果没有就创建ses ...

  5. iconfont阿里巴巴矢量图标库批量保存

    F12输入——var iconList = document.querySelectorAll('.icon-gouwuche1');for (var i = 0; i < iconList.l ...

  6. 计算给定多项式在给定点X处的值

    //计算多项式求值 //计算多项式求值#include<iostream>#include<ctime>#include<cmath>using namespace ...

  7. SVN被锁定的几种解决方法

    用SVN经常出现被锁定而无法提交的问题,选择解锁又提示没有文件被锁定,很是头疼.这里整理了一下SVN被锁定的几种解决方法: 1.出现这个问题后使用“清理”即"Clean up"功能 ...

  8. Linux学习(1)- TCP/IP网络协议基础

    Linux学习(1)- TCP/IP网络协议基础 一.TCP/IP 简介 学习内容 TCP/IP(Transmission Control Protocol/Internet Protocol)是传输 ...

  9. 后台开发 - DPDK引发的图谱

    关系图谱(点击看完整大图): 部分名词: 名词 全写 解释 备注 DPDK Data Plane Development Kit 数据平面开发套件或叫数据平面开发工具集 Intel开源的快速数据包处理 ...

  10. 2017-12-24 自定义view相关学习

    学习材料: http://blog.csdn.net/u010661782/article/details/52805870 http://blog.csdn.net/chengyingzhilian ...