【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 ...
随机推荐
- mybatis 注解写法 多层嵌套foreach,调用存储过程,批量插入数据
@Select("<script>" + "DECLARE @edi_Invoice_Details edi_Invoice_Details;" + ...
- 【409】Linux 系统 Testrun
文件名:Testrun #!/bin/sh PROG=./puzzle case $1 in 1) T=Tests/bad* ;; 2) T=Tests/sol* ;; 3) T=Tests/unso ...
- js滚轮事件需要注意的兼容性问题
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...
- HTTP请求 响应状态码
1.请求响应方式 get是从服务器上获取数据,post是向服务器传送数据.get 数据在地址栏中明文的形式发送, post则不是,传递的数据比get多 据RFC2616标准(现行的HT ...
- SP1043 GSS1 - Can you answer these queries I(猫树)
给出了序列A[1],A[2],…,A[N]. (a[i]≤15007,1≤N≤50000).查询定义如下: 查询(x,y)=max{a[i]+a[i+1]+...+a[j]:x≤i≤j≤y}. 给定M ...
- Sql 主键设置
1.开发数据库时常用命名规范 1>.使用不包含数字的单数表名,如果必要的话可以增加模块名前缀. 2>.对于主键的命名,使用表名+ID的形式. 3>.作为外键的列的名字应该与它们所对应 ...
- Net 发布网站中遇到的几点问题
1.windows 身份验证设置 打开IIS==>=>找到网站==> 身份验证==>打开功能==>启用windows身份验证 网站设置: 博客参考: http://blo ...
- 【工具】Github
项目目录结构设计与git远程仓库的建立 git码云仓库建立:在码云网站上新建组织和项目. 配置sshkey认证和公钥:命令行ssh-keygen -t rsa -C "xxxxx@xxxxx ...
- 前端--2、CSS基础
CSS的部分: CSS四种类引入方式(了解) style的定义原则: 基本选择器 示例: 层级选择器 组合选择器 后代选择器 ★ 子代选择器 毗邻选择器 普通兄弟选择器 “与”选择器 ★ “或”选择器 ...
- Android电池电量跳变
高通平台8916/8917 对于第三方Fuel Gauge,跳变多是因为IC内部算法的问题,这样我们可以通过驱动来规避. 例如:usb在位时,要阻止电量的向下跳变. 当电量越级跳变时,要在驱动中能检测 ...