Codeforces Round #196 (Div. 2) B. Routine Problem
screen 尺寸为a:b
video 尺寸为 c:d
如果a == c 则 面积比为 cd/ab=ad/cb (ad < cb)
如果b == d 则 面积比为 cd/ab=cb/ad (cb < ad)
如果不相等时
如果a/b > c/d,则ad/bd > cb/db 则(ad > cb)
screen尺寸可为 ad:bd, video的尺寸可为 cb:db
面积比为:cb*db/ad*bd = cb/ad (ad > cb)
如果a/b < c/d,则ac/bc < ca/da 则(ad < cb)
screen尺寸可为 ac:bc, video的尺寸可为 ca:da
面积比为:ca*da/ac*bc = ad/cb (ad < cb)
综合得面积比为min(ad,cb)/max(ad,cb)
#include <iostream>
#include <vector>
#include <algorithm> using namespace std; int gcd(int n, int m){
while(m){
int t = n%m;
n = m;
m = t;
}
return n;
} int main(){
int a,b,c,d;
cin >> a >> b >> c >> d;
int video = c*b, screen = a*d;
if(video > screen) swap(screen,video);
int k = gcd(screen,video);
video/=k;screen/=k;
cout<<screen-video<<"/"<<screen<<endl;
}
Codeforces Round #196 (Div. 2) B. Routine Problem的更多相关文章
- Codeforces Round #367 (Div. 2) C. Hard problem
题目链接:Codeforces Round #367 (Div. 2) C. Hard problem 题意: 给你一些字符串,字符串可以倒置,如果要倒置,就会消耗vi的能量,问你花最少的能量将这些字 ...
- Codeforces Round #603 (Div. 2) A. Sweet Problem(水.......没做出来)+C题
Codeforces Round #603 (Div. 2) A. Sweet Problem A. Sweet Problem time limit per test 1 second memory ...
- Codeforces Round #367 (Div. 2) C. Hard problem(DP)
Hard problem 题目链接: http://codeforces.com/contest/706/problem/C Description Vasiliy is fond of solvin ...
- Codeforces Round #196 (Div. 1 + Div. 2)
A. Puzzles 对\(f[]\)排序,取连续的\(m\)个. B. Routine Problem 考虑\(\frac{a}{b}\)和\(\frac{c}{d}\)的大小关系,适配后就是分数的 ...
- Codeforces Round #361 (Div. 2) C.NP-Hard Problem
题目连接:http://codeforces.com/contest/688/problem/C 题意:给你一些边,问你能否构成一个二分图 题解:二分图:二分图又称作二部图,是图论中的一种特殊模型. ...
- Codeforces Round #196 (Div. 2) D. Book of Evil 树形dp
题目链接: http://codeforces.com/problemset/problem/337/D D. Book of Evil time limit per test2 secondsmem ...
- Codeforces Round #360 (Div. 2) C. NP-Hard Problem 水题
C. NP-Hard Problem 题目连接: http://www.codeforces.com/contest/688/problem/C Description Recently, Pari ...
- Codeforces Round #603 (Div. 2) A. Sweet Problem(数学)
链接: https://codeforces.com/contest/1263/problem/A 题意: You have three piles of candies: red, green an ...
- Codeforces Round #198 (Div. 2) C. Tourist Problem
C. Tourist Problem time limit per test 1 second memory limit per test 256 megabytes input standard i ...
随机推荐
- linux文件描述符open file descriptors与open files的区别
一个文件被打开,也可能没有文件描述符,比如current working diretories,memory mapped files and executable text files ;losf可 ...
- C#的yield关键字
using System; using System.Collections.Generic; using System.Reflection; using System.Text.RegularEx ...
- Algorithms, Part I by Kevin Wayne, Robert Sedgewick
Welcome to Algorithms, Part I 前言 昨天在突然看到了Coursera上Robert Sedgewick讲的Algorithms,Part II看了一些,甚是爽快,所以又去 ...
- 算法系列:geometry
1.基本几何变换及变换矩阵 基本几何变换都是相对于坐标原点和坐标轴进行的几何变换,有平移.比例.旋转.反射和错切等. 1.1 平移变换 是指将p点沿直线路径从一个坐标位置移到另一个坐标位置的重定位过程 ...
- 使用zookeeper实现分布式锁
简介: 核心是解决资源竞争的问题 分布式系统中经常需要协调多进程或者多台机器之间的同步问题,得益于zookeeper,实现了一个分布式的共享锁,方便在多台服务器之间竞争资源时,来协调各系统之间的协作和 ...
- Golang Beego 分析(一)
关于注解路由,实质上其实是comment route. 作者使用ast自动生成注册代码,实质上感觉是画蛇添足了. 有一定的使用价值,但是在代码管理上反而混乱了.所以本人建议不要使用此项特性.
- memcached基于socket访问memcache缓存服务器
memcached基于socket访问memcache缓存服务器 操作memcache常用三种方法: .memcache基于php_memcache.dll扩展(php扩展) .memcached基于 ...
- hdu 1866 几个矩形面积的和 ***
给出几个矩形,求出面积之和,相交区域只能算一次 一开始想用线段树求个并,后来发现没办法知道并了几次,然后就不会了 看了题解 本题其实很简单,但是想要想到转化也很不容易,因为本题是求面积之和,但是两个矩 ...
- Codeforces Round #369 (Div. 2) C. Coloring Trees DP
C. Coloring Trees ZS the Coder and Chris the Baboon has arrived at Udayland! They walked in the pa ...
- 处理FF margin-top下降问题
处理DIV子级ZImargin-top下降,父级更着下降问题 html结构如下 <div id="top"> <div id="zi"> ...