CF111A Petya and Inequiations 题解】的更多相关文章

Content 请找出一个由 \(n\) 个正整数组成的数列 \(\{a_1,a_2,\dots,a_n\}\),满足以下两种条件: \(\sum\limits_{i=1}^na_i^2\geqslant x\). \(\sum\limits_{i=1}^na_i\leqslant y\). 数据范围:\(1\leqslant n\leqslant 10^5\),\(1\leqslant x\leqslant 10^{12}\),\(1\leqslant y\leqslant 10^6\). S…
A. Petya and Inequiations Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/111/problem/A Description Little Petya loves inequations. Help him find n positive integers a1, a2, ..., an, such that the following two conditions a…
题目:Petya and Inequiations传送门: http://codeforces.com/problemset/problem/111/A http://codeforces.com/problemset/problem/112/C 分析: 先引一个简单的结论:“(a+b)^2>=a^2+b^2”,可得一个简单的贪心:让其中一个数越大越好:再从“a[1] + a[2] + ... + a[n] <= y”入手:让a[1]越大越好,a[2].a[3]...a[n]都为1:如果这种构…
Content 小 P 想给 \(n\) 位朋友各发一张邀请函,每张邀请函需要耗费 \(2\) 张红色纸,\(5\) 张绿色纸和 \(8\) 张蓝色纸.商店里面的纸是一堆一堆卖的,每堆里面有 \(k\) 张只含有红.绿.蓝三种颜色中的一个颜色的纸.求小 P 至少要买多少堆. 数据范围:\(1\leqslant n,k\leqslant 10^8\). Solution 直接看每种颜色需要多少堆,由于只能一堆一堆地买,所以只能多买,不能少买,因此答案就很显而易见了,分别是 \(\left\lcei…
原来这就叫构造题,了 这道题的做法,我自己诌了一个形象的名字--"挂葡萄"法( 首先,"搭葡萄架":考虑到每个距离 \(d_i\) 只与 \(2i-1,2i\) 有关,\(2i-1\) 与 \(2(i+1)-1\) 之间的距离是可以随意设置的,那不妨把所有的奇数编号串成一条链(不过注意,链上的编号不一定是按顺序的,因为要顺应题目要求的距离). 然后,"挂葡萄":将 \(d\) 数组降序排序,对于每个 \(d_i\),将其按照距离挂在 \(i+d_…
网址:http://codeforces.com/contest/576/problem/A A. Vasya and Petya's Game time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Vasya and Petya are playing a simple game. Vasya thought of number x…
B. Petya and Divisors Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/111/problem/B Description Little Petya loves looking for numbers' divisors. One day Petya came across the following problem: You are given n queries in t…
C. Vasya and Petya's Game Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/577/problem/C Description Vasya and Petya are playing a simple game. Vasya thought of number x between 1 and n, and Petya tries to guess the number. P…
补的若干年以前的题目,水题,太菜啦_(:з」∠)_    B. Petya and Exam time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output It's hard times now. Today Petya needs to score 100 points on Informatics exam. The tasks see…
D. Petya and Array time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Petya has an array aa consisting of nn integers. He has learned partial sums recently, and now he can calculate the sum o…