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…
一部分题解,算是自己SB了 上午的TC 也是这样 写好了代码,却一直没注意细节,然后以为错了. 此处省100字,ps 貌似紫了,作为一个老菜鸡,终于紫了 A,B 都是语文题 C: 给以一个三角形一样的图,判断点(a,b)是否在图中,我是这样判断的: 前一半是k*2*x+b=a;求最小的x,这里二分,但是注意k=0,所以你特判掉: 后一半是:2*(k+1)=a+b;二分类似 D:坐等官方题解,不靠谱系列:我试了很多方法: 做法:只可能是一个数*x^k: 之前以为是最大数*x^k ,但是错的 想想:…
                                                                        D. "Or" Game                                                                             time limit per test 2 seconds You are given n numbers a1, a2, ..., an. You can perfo…
                                                                       C. A Problem about Polyline                                                                                time limit per test 1 second                                            …
                                                                  B. Finding Team Member                                                                               time limit per test 2 seconds                                                      …
Pythagorean Triples 题目链接: http://codeforces.com/contest/707/problem/C Description Katya studies in a fifth grade. Recently her class studied right triangles and the Pythagorean theorem. It appeared, that there are triples of positive integers such th…
Codeforces Round #622 (Div. 2) B. Different Rules 题意: 你在参加一个比赛,最终按两场分赛的排名之和排名,每场分赛中不存在名次并列,给出参赛人数 n 和你两场分赛的排名 x, y,问你最终名次最小和最大可能是多少. 思路: 以8人为例: x + y = 2,最小第一名,最大第一名:               1 2 3 4 5 6 7 8 8 7 6 5 4 3 2 1               x + y = 3,最小第一名,最大第二名.…
1.前言 虽然这次我依旧没有参加正式比赛,但是事后还是看了看题目的...一般不怎么刷Codeforces. A.Raising Bacteria You are a lover of bacteria. You want to raise some bacteria in a box. Initially, the box is empty. Each morning, you can put any number of bacteria into the box. And each night…
解题思路:就是求数 n 对应的二进制数中有多少个 1 #include <iostream> #include<cstdio> using namespace std; int main(){ int n; cin>>n; ; // while(n){//这也是一种好的方法 // n = n&(n-1); // ++ans; // } while(n){ ) ++ans; n>>=; } cout<<ans<<endl; ;…
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…
题意:一个等腰直角三角形一样的周期函数(只有x+轴),经过给定的点(a,b),并且半周期为X,使X尽量大,问X最大为多少? 如果a=b,结果就为b 如果a<b无解. 否则,b/(2*k*x-a)=1或者b/(a-2*k*x)=1;以前者为例,x=(a-b)/(2*k).x越小越好,那么k尽量大,但是K过大,x就会小于b,x小于b就无法穿过(a,b).k要大又不能过大就满足二分的要求,就能二分. 乱码: //#pragma comment(linker,"/STACK:1024000000,…
题意:一个数组arr,一个数字x,要使arr-x的最大子段最小,问该最小值. 三分x,复杂度logn,内层是最大子段的模板,只能用n复杂度的.因为是绝对值最大,正负各求一次,取大的.精度卡得不得了,要1e-12左右才能过.看着数据才调出精度的. 乱码: //#pragma comment(linker,"/STACK:1024000000,1024000000") #include<iostream> #include<cstdio> #include<s…
题意:n个数字,最多操作k次,每次乘x,要使结果数组的与值最大. 能推断出结果是对一个元素操作k次,并且这个元素的二进制最高位比较大.并不一定是取最大的,比如1100和1010,乘以一次2,两种选法分别为11000|1010=11010,:::1100|10100=11100后者更大. 有没有可能k次乘在不同的数字上呢?不可能.如果有3个数字abc二进制最高位都是第5位,k=3,x=2,假如乘了一次a,再乘两次a,与的结果是8位.如果放弃a,去乘别的,只有7位以下. 实现过程中,用一个数组arr…
A. Watching a movie time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output You have decided to watch the best moments of some movie. There are two buttons on your player: Watch the current minute…
题目链接: http://codeforces.com/contest/712/problem/E 题目大意: 一条直线上有n格,在第i格有pi的可能性向右走一格,1-pi的可能性向左走一格,有2中操作:单点修改pi以及询问从L格出发最终从R格离开区间[L,R]的概率. 这题在cf上A的人比较少,本来不打算去做的,然后看了下是概率的题目,比较感兴趣,就去做了下,然后发现并不会做,就搜了题解. 题解: 参考http://www.cnblogs.com/qscqesze/p/5868047.html…
C. Gerald's Hexagon Time Limit: 2 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/559/problem/A Description Gerald got a very curious hexagon for his birthday. The boy found out that all the angles of the hexagon are equal to . Then he me…
题目链接 这个题取模的时候挺坑的!!! 题意:div(x , b) / mod(x , b) = k( 1 <= k <= a).求x的和 分析: 我们知道mod(x % b)的取值范围为 1  - (b-1).那么我们可以从这一点入口来进行解题.. mod (x, b) = 1 时, x  =  b + 1, 2b + 1, 3b + 1..... a * b + 1. mod (x , b) = 2 时, x =  2b + 2, 4b + 2, 6b + 2, ..... 2a * b…
A. Pasha and Stick 题目连接: http://www.codeforces.com/contest/610/problem/A Description Pasha has a wooden stick of some positive integer length n. He wants to perform exactly three cuts to get four parts of the stick. Each part must have some positive…
B. Vanya and Books Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/552/problem/B Description Vanya got an important task — he should enumerate books in the library and label each book with its number. Each of the n books sh…
E. Vanya and Field Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/492/problem/E Description Vanya decided to walk in the field of size n × n cells. The field contains m apple trees, the i-th apple tree is at the cell with…
C. The Big Race Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/592/problem/C Description Vector Willman and Array Bolt are the two most famous athletes of Byteforces. They are going to compete in a race with a distance of…