【Codeforces 1030D】Vasya and Triangle
【链接】 我是链接,点我呀:)
【题意】
题意
【题解】
参考这篇题解:https://blog.csdn.net/mitsuha_/article/details/82825862
为什么可以保证m*gcd(2*n,k)/k是一个整数?
因为先前已经判断过
2*n*m/k是可以整除的。
显然k是被2*n和m两个数字除了之后变成1
2*n贡献的那一部分其实就是gcd(2*n,k)
那么我们显然可以直接用gcd(2*n,k)来代表2*n
所以右边肯定也是能整除的。
且
【代码】
#include <bits/stdc++.h>
using namespace std;
const int N = 50;
const long long M = 15e6;
long long n,m,k;
long long x1,y1,x2,y2,x3,y3;
int main(){
ios::sync_with_stdio(0),cin.tie(0);
cin >> n >> m >> k;
if ( (2*n*m)%k!=0){
cout<<"NO"<<endl;
}else{
long long temp = __gcd(2*n,k);
if (temp>1){
x2 = 2*n/temp;
y3 = m*temp/k;
}else{
temp = __gcd(2*m,k);
x2 = n*temp/k;
y3 = 2*m/temp;
}
cout<<"YES"<<endl;
cout<<x1<<" "<<y1<<endl;
cout<<x2<<" "<<y2<<endl;
cout<<x3<<" "<<y3<<endl;
}
return 0;
}
【Codeforces 1030D】Vasya and Triangle的更多相关文章
- 【Codeforces 493C】Vasya and Basketball
[链接] 我是链接,点我呀:) [题意] 题意 [题解] 枚举三分线(离散后)的位置 然后根据预处理的前缀和,快速算出两个队伍的分数. [代码] #include <bits/stdc++.h& ...
- 【Codeforces 493D】Vasya and Chess
[链接] 我是链接,点我呀:) [题意] [题解] 会发现两个皇后之间如果只有奇数个位置 也就是n%2==1 那么第二个人总是赢的 因为如果white往下跑的话,black也能往下跑. 第二个人没有输 ...
- 【CodeForces 577C】Vasya and Petya’s Game
链接 某个数x属于[1,n],至少询问哪些数“x是否是它的倍数”才能判断x.找出所有质因数和质因数的幂即可. #include<cstdio> #include<algorithm& ...
- 【codeforces 415D】Mashmokh and ACM(普通dp)
[codeforces 415D]Mashmokh and ACM 题意:美丽数列定义:对于数列中的每一个i都满足:arr[i+1]%arr[i]==0 输入n,k(1<=n,k<=200 ...
- 【codeforces 766B】Mahmoud and a Triangle
time limit per test2 seconds memory limit per test256 megabytes inputstandard input outputstandard o ...
- 【25.33%】【codeforces 552D】Vanya and Triangles
time limit per test4 seconds memory limit per test512 megabytes inputstandard input outputstandard o ...
- 【22.70%】【codeforces 591C】 Median Smoothing
time limit per test2 seconds memory limit per test256 megabytes inputstandard input outputstandard o ...
- 【23.26%】【codeforces 747D】Winter Is Coming
time limit per test1 second memory limit per test256 megabytes inputstandard input outputstandard ou ...
- 【codeforces 707E】Garlands
[题目链接]:http://codeforces.com/contest/707/problem/E [题意] 给你一个n*m的方阵; 里面有k个联通块; 这k个联通块,每个连通块里面都是灯; 给你q ...
随机推荐
- XHTML与HTML区别
1.一下规则适用于XHTML,但并不适用于HTML <html>.<head>.<body>都是必需的标签 必须设置<html>标签的xmlns属性,且 ...
- nodejs常用命令
npm是一个node包管理和分发工具,已经成为了非官方的发布node模块(包)的标准.有了npm,可以很快的找到特定服务要使用的包,进行下载.安装以及管理已经安装的包. 1.npm install m ...
- Mybatis 分页实现
一.插件 PageHelper(推荐使用) 原理:利用Mybatis的拦截器,截获需要分页的sql语句,在语句后面加分页条件,及获取总记录数等属性. 注意 插件属性类 参考一 参考二 实例: 第一步: ...
- hdu4292 Food 最大流模板题
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4292 题意:水和饮料,建图跑最大流模板. 我用的是学长的模板,最然我还没有仔细理解,不过这都不重要直接 ...
- js 上传头像
css .con4{width: 230px;height: auto;overflow: hidden;margin: 20px auto;color: #FFFFFF;} .con4 .btn{w ...
- (DP)51NOD 1049 最大子段和
N个整数组成的序列a[1],a[2],a[3],…,a[n],求该序列如a[i]+a[i+1]+…+a[j]的连续子段和的最大值.当所给的整数均为负数时和为0. 例如:-2,11,-4,13,-5 ...
- 洛谷 P1233 木棍加工
题目描述 一堆木头棍子共有n根,每根棍子的长度和宽度都是已知的.棍子可以被一台机器一个接一个地加工.机器处理一根棍子之前需要准备时间.准备时间是这样定义的: 第一根棍子的准备时间为1分钟: 如果刚处理 ...
- python 操作数据库时遇到的错误
pymysql.err.ProgrammingError: (1064, "You have an error in your SQL syntax; ch 之前的写法是从文件里 ...
- [APIO2007]动物园
题目描述 新建的圆形动物园是亚太地区的骄傲.圆形动物园坐落于太平洋的一个小岛上,包含一大圈围栏,每个围栏里有一种动物. 你是动物园的公共主管.你要做的是,让每个来动物园的人都尽可能高兴.今天有一群小朋 ...
- [转]Windows Azure平台简介(一):定位与产品结构
本文转自:http://blog.csdn.net/azurechina/article/details/5592236 http://blogs.msdn.com/b/azchina/archive ...