C. Weakness and Poorness Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/578/problem/C Description You are given a sequence of n integers a1, a2, ..., an. Determine a real number x such that the weakness of the sequence a1 -…
B. "Or" Game Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/578/problem/B Description You are given n numbers a1, a2, ..., an. You can perform at most k operations. For each operation you can multiply one of the number…
题目链接:http://codeforces.com/contest/578/problem/B 题目大意:现在有n个数,你可以对其进行k此操作,每次操作可以选择其中的任意一个数对其进行乘以x的操作.思路:最先想到的办法是贪心,也就是选择数组中最大的那个数对它进行k次乘以x的操作.但是这种方法在有的时候会出现错误,如测试数据的第三组:2 1 212 9这种情况下有2个数,我能够对其进行1次乘以2的操作,如果以之前贪心的方法,选择12乘以2,那么得到的结果(12*2)|9=25,但是如果选择9乘以…
E. Weakness and Poorness time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output You are given a sequence of n integers a1, a2, ..., an. Determine a real number x such that the weakness of the seq…
A. Raising Bacteria time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output You are a lover of bacteria. You want to raise some bacteria in a box. Initially, the box is empty. Each morning, you can…
D. "Or" Game time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output You are given n numbers a1, a2, ..., an. You can perform at most k operations. For each operation you can multiply one of…
E. Weakness and Poorness time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output You are given a sequence of n integers a1, a2, ..., an. Determine a real number x such that the weakness of the seq…
显然f(x)是个凹函数,三分即可,计算方案的时候dp一下.eps取大了会挂精度,指定循环次数才是正解. #include<bits/stdc++.h> using namespace std; ; ; double a[maxn]; double d1[maxn],d2[maxn]; int n; inline double cal(double x) { ., a2 = .; ; i <= n; i++){ d1[i] = max(.,d1[i-])+a[i]-x; a1 = max(…
首先应该保证二进制最高位尽量高,而位数最高的数乘x以后位数任然是最高的,所以一定一个数是连续k次乘x. 当出现多个最高位的相同的数就枚举一下,先预处理一下前缀后缀即可. #include<bits/stdc++.h> using namespace std; ; int a[maxn]; int pf[maxn],sf[maxn]; int main() { int n,k,x; scanf("%d%d%d",&n,&k,&x); ; i <=…
题目中给出的函数具有周期性,总可以移动到第一个周期内,当然,a<b则无解. 假设移动后在上升的那段,则有a-2*x*n=b,注意限制条件x≥b,n是整数,则n≤(a-b)/(2*b).满足条件的x≥(a-b)/(2*n) 假设在下降的那段,2*x-(a-2*x*n)=b,n+1≤(a+b)/(2*b),x≥(a+b)/(2*(n+1)) 两者取最小值 #include<bits/stdc++.h> using namespace std; int main() { int a,b; sc…