CodeForces 525C Ilya and Sticks 贪心】的更多相关文章

题目:click here #include <iostream> #include <cstdio> #include <cstring> #include <algorithm> typedef long long ll; using namespace std; const int M = 1e5+5; int n; int a[M]; int b[M]; bool cmp( int a, int b ) { //从大到小排序 return a >…
Codeforces Round #297 (Div. 2)C. Ilya and Sticks Time Limit: 2 Sec  Memory Limit: 256 MBSubmit: xxx  Solved: 2xx 题目连接 http://codeforces.com/contest/525/problem/C Description In the evening, after the contest Ilya was bored, and he really felt like ma…
C. Ilya and Sticks time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output In the evening, after the contest Ilya was bored, and he really felt like maximizing. He remembered that he had a set of …
题目传送门 /* 题意:给n个棍子,组成的矩形面积和最大,每根棍子可以-1 贪心:排序后,相邻的进行比较,若可以读入x[p++],然后两两相乘相加就可以了 */ #include <cstdio> #include <algorithm> #include <cstring> #include <cmath> using namespace std; typedef long long ll; ; const int INF = 0x3f3f3f3f; in…
C. Ilya and Sticks time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output In the evening, after the contest Ilya was bored, and he really felt like maximizing. He remembered that he had a set of…
点击打开链接 1270: Wooden Sticks [贪心] 时间限制: 1 Sec 内存限制: 128 MB 提交: 31 解决: 11 统计 题目描述 Lialosiu要制作木棍,给n根作为原料的木棍的长度和重量.根据要求求出制作木棍的最短时间. 首先我们知道制作第一个木棍需要1分钟,若是接着要制作的木棍的重量和长度都不少于当前的木棍,那么就不需要建立的时间,若是没有,则再需要建立时间,也就是1分钟. 举个例子,如果你有五个原料木棍,他们的长度和重量分别是(4,9), (5,2), (2,…
题目:http://codeforces.com/gym/100338/attachments 贪心,每次枚举10的i次幂,除k后取余数r在用k-r补在10的幂上作为候选答案. #include<bits/stdc++.h> using namespace std; typedef unsigned long long ull; ; ull base[maxbit], n, k; void preDeal() { ] = ; ; i < maxbit; i++){ *]; } } voi…
[Codeforces 1214A]Optimal Currency Exchange(贪心) 题面 题面较长,略 分析 这个A题稍微有点思维难度,比赛的时候被孙了一下 贪心的思路是,我们换面值越小的货币越优.如有1,2,5,10,20,50,那么我们尽量用面值为1的.如果我们把原始货币换成面值为x的货币,设汇率为d,那么需要的原始货币为dx的倍数.显然dx越小,剩下的钱,即n取模dx会尽量小. 然后就可以枚举换某一种货币的数量,时间复杂度\(O(\frac{n}{d})\) 代码 #inclu…
Problem description In the evening, after the contest Ilya was bored, and he really felt like maximizing. He remembered that he had a set of n sticks and an instrument. Each stick is characterized by its length li. Ilya decided to make a rectangle fr…
Codeforces Global Round 2 题目链接: E. Pavel and Triangles Pavel has several sticks with lengths equal to powers of two. He has \(a_0\) sticks of length \(2^0=1\), \(a1\) sticks of length \(2^1=2\), ..., \(a_{n−1}\) sticks of length \(2^{n−1}\). Pavel wa…