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                                                      …
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…
D. Soldier and Number Game time limit per test 3 seconds memory limit per test 256 megabytes input standard input output standard output Two soldiers are playing a game. At the beginning first of them chooses a positive integer n and gives it to the…
题目链接: http://codeforces.com/contest/740/problem/D D. Alyona and a tree time limit per test2 secondsmemory limit per test256 megabytes 问题描述 Alyona has a tree with n vertices. The root of the tree is the vertex 1. In each vertex Alyona wrote an positiv…
题目链接: http://www.codeforces.com/contest/666/problem/B 题意: 给你n个城市,m条单向边,求通过最短路径访问四个不同的点能获得的最大距离,答案输出一个满足条件的四个点. 题解: 首先预处理出任意两点的最短距离,用队列优化的spfa跑:O(n*n*logn) 现依次访问四个点:v1,v2,v3,v4 我们可以枚举v2,v3,然后求出v2的最远点v1,v3的最远点v4,为了保证这四个点的不同,直接用最远点会错,v1,v4相同时还要考虑次最远点来替换…
A. Mike and palindrome time limit per test:2 seconds memory limit per test:256 megabytes input:standard input output:standard output Mike has a string s consisting of only lowercase English letters. He wants to change exactly one character from the s…
B. Covered Path Time Limit: 1 Sec  Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/534/problem/B Description The on-board computer on Polycarp's car measured that the car speed at the beginning of some section of the path equals v1 meters per…
转载自:https://blog.csdn.net/Charles_Zaqdt/article/details/87522917 题目链接:https://codeforces.com/contest/1113/problem/C        题意是给了n个数字,让找出一个长度为偶数的区间[l, r],使得al ^ al+1 ^ .... ^ amid = amid + 1 ^ ... ^ ar这个等式成立(l到mid的异或和等于mid+1到r的异或和),求出有多少个满足要求的区间.    …
题目链接:https://codeforces.com/contest/1362/problem/B 题意 有一个大小及元素值均不超过 $1024$ 的正整数集合,求最小正整数 $k$,使得集合中的每个元素异或 $k$ 后得到的新集合与原集合相等,若这样的 $k$ 不存在输出 $-1$ . 题解 数据范围较小,枚举即可. 代码 #include <bits/stdc++.h> using namespace std; void solve() { int n; cin >> n;…
B. Hamming Distance Sum   Genos needs your help. He was asked to solve the following programming problem by Saitama: The length of some string s is denoted |s|. The Hamming distance between two strings s and t of equal length is defined as , where si…
解题报告 http://blog.csdn.net/juncoder/article/details/38102391 题意: n场比赛当中k场是没看过的,对于这k场比赛,a,b,c三队赢的场次的关系是a队与b队的绝对值差d1,b队和c队绝对值差d2,求能否使三支球队的赢的场次同样. 思路: |B-A|=d1 |C-B|=d2 A+B+C=k 这样就有4种情况,各自是: B>A&&C<B B>A&&C>B B<A&&C<B…
A. Karen and Morning time limit per test 2 seconds memory limit per test 512 megabytes input standard input output standard output Karen is getting ready for a new school day! It is currently hh:mm, given in a 24-hour format. As you know, Karen loves…