Codeforces Round #509 (Div. 2)B題Buying a TV Set
#include<bits/stdc++.h>
using namespace std;
int main() {
long long a, b, x, y, g;
cin >> a >> b >> x >> y;
g = __gcd(x, y);
x /= g;
y /= g;
cout << min(a / x, b / y);
}
本題目的意思是商店中有任意高和寬的電視螢幕,在w<=a,h<=b的條件下求有多少塊螢幕w/h符合特定的比例x/y。
先求出最小公約數g,再利用此最小公約數將x/y化成最簡比例,這個比例本身代表了符合要求的最小螢幕,然後看a,b範圍內有之快最小螢幕的整數倍螢幕共幾塊,a/x,b/y中比較小的那一個即為題解(螢幕必須既符合w<=a,又符合h<=b,所以取更小值)
相關推薦
Codeforces Round #509 (Div. 2)B題Buying a TV Set
#include<bits/stdc++.h> using namespace std; int main() { long long a, b, x, y, g; cin >> a >> b >> x >&g
Codeforces Round #482 (Div. 2) B題
BE 題意 www. finally tdi code fir eterm htm B. Treasure Hunt time limit per test1 second memory limit per test:256 megabytes i
Codeforces Round #248 (Div. 2) B題 【資料結構:樹狀陣列】
題目大意:給n(1 ≤ n ≤ 105)個數據(1 ≤ vi ≤ 109),其中有m(1 ≤ m ≤ 105)個問題,分兩種,第一種:給出l,r,讓你求出v[l],v[r]之間的所有資料和;第二種:
Codeforces Round #402 (Div. 2) B題
B. Weird Rounding time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output P
Codeforces Round #524 (Div. 2) B. Margarite and the best present 規律題
B. Margarite and the best present time limit per test 1 second memory limit per test 256 megabytes input standard input output stand
【Codeforces Round #509 (Div. 2)】A,B,C,D
這是蒟蒻的真·第一場CF...所以其實升了1500+還是不錯吧? 題意:找包含給出的n個數的最短連續序列,輸出新加入的數的最小個數。 分析:排序+掃描即可。 #include<i
Codeforces Round #493 (Div. 2) B. Cutting 字首和優化_動歸水題
不解釋,題目過水 Code: #include<cstdio> #include<cmath> #include<algorithm> using namespace std; const int maxn = 1000 +
Codeforces Round #225 (Div. 2)(B思維題,E:dfs+樹狀陣列)
A. Coder 題意:在一張網格上放置棋子,他能攻擊到上下左右的地方,問最多放多少棋子,使其不能相互攻擊到,輸出一種方法; 思路:從第一個開始放,標記其上下左右。 #include<iost
想法題——Codeforces Round #190 (Div. 2)——B. Ciel and Flowers
B. Ciel and Flowers time limit per test 1 second memory limit per test 256 megabytes input standard input output standard out
水題-Codeforces Round #369 Div.2-B
B. Chris and Magic Square time limit per test2 seconds memory limit per test256 megabytes inputstandard input outputstandard ou
Codeforces Round #388 (Div. 2) B
special def contain coo parallel mes c++ clu tps Long time ago Alex created an interesting problem about parallelogram. The input da
Codeforces Round #426 (Div. 2)B. The Festive Evening
color pac i++ bit main size -- end bits 題意:有26個城門,k個守衛,給出每個城門人進入的順序,只有當這個城門進入的人是最後一個,該城門的守衛才能去別的城門,問是否有個時間段,守衛不夠用 思路:記錄起始,模擬下 1 #includ
Codeforces Round #442 (Div. 2) B. Nikita and string
style force c++ its class char 每次 包含 子串 題意:給一個字符串,問形如a……a/ /b……b/ /a……a的子串最大長度 題解:設三個狀態a,ab,aba分別表示對應長度。因為每段長度可以為0,所以後一個狀態的包含前一個狀態。每次更新
Codeforces Round #448 (Div. 2) B. XK Segments【進制思維/排序】
swe 不同 example 整數 number this put class and B. XK Segments time limit per test 1 second memory limit per test 256 megabytes
Codeforces Round #267 (Div. 2) B. Fedor and New Game【位運算/給你m+1個數讓你判斷所給數的二進制形式與第m+1個數不相同的位數是不是小於等於k,是的話就累計起來】
ons ecif 否則 ans contain rst rmi sum any After you had helped George and Alex to move in the dorm, they went to help their friend
Codeforces Round #470 (Div 2) B 數學 C 二分+樹狀數組 D 字典樹
fin -i insert 數組 字典 main esp ace blog Codeforces Round #470 B. Primal Sport 數學題,對 x2 和 x1 分解質因子即可。 #include<bits/stdc++.h>
Codeforces Round #471 (Div. 2)B. Not simply beatiful strings
check cto oss sin and whether strlen ssi dash Let‘s call a string adorable if its letters can be realigned in such a way that they form
Codeforces Round #484 (Div. 2) B. Bus of Characters(markdowm版)
flag ron 數據 names rac AR string 輸入 實現 Codeforces Round #484 (Div. 2) B. Bus of Characters B. Bus of Characters time limit per test 2 seco
【思維】Codeforces Round #485 (Div. 2) B. High School: Become Human(對數)
space scanf CA ace ima AC bsp ont http 題目鏈接:http://codeforces.com/contest/987/problem/B 在運算的時候取對數就好了 1 #include <bits/stdc++
Codeforces Round #485 (Div. 2) C題求三元組(思維)
rip ORC 它的 printf ble CA BE byte order C. Three displays time limit per test 1 second memory limit per test 256 megabytes input s