Codeforces 1240A. Save the Nature】的更多相关文章

传送门 显然可以二分答案 如果知道卖的票数,那么就能算出有多少 $a$ 倍数但不是 $b$ 倍数的位置,多少 $b$ 倍数但不是 $a$ 倍数的位置,多少既是 $a$ 又是 $b$ 倍数的位置 然后贪心地把每张票分配给那些位置即可 把价格从大到小排序并预处理前缀和就可以 $O(1)$ 求出最大收益了 #include<iostream> #include<cstdio> #include<algorithm> #include<cstring> #inclu…
https://codeforces.com/contest/1241/problem/C You are an environmental activist at heart but the reality is harsh and you are just a cashier in a cinema. But you can still do something! You have n tickets to sell. The price of the i-th ticket is pi.…
链接: https://codeforces.com/contest/1241/problem/C 题意: You are an environmental activist at heart but the reality is harsh and you are just a cashier in a cinema. But you can still do something! You have n tickets to sell. The price of the i-th ticket…
B. Save the problem! http://codeforces.com/contest/867/problem/B time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Attention: we lost all the test cases for this problem, so instead of solvi…
A. Save Luke time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Luke Skywalker got locked up in a rubbish shredder between two presses. R2D2 is already working on his rescue, but Luke needs to…
题意: 一个炉子烤鸡,炉子打开的时候一共$T$分钟可以烤完,关闭的时候一共$2T$分钟可以烤完,炉子每$K$分钟自动关闭,厨师每$D$分钟回来检查,打开炉子 问多长时间烤完.. 题解: 用整数写比较稳妥.. 显然,整个过程是呈周期性的. $K>D , t_r = D*(\left \lfloor\frac{K}{D} \right \rfloor +1)  $ $K<=D,  t_r =D$ 将总时间$T*2$,那每个周期提供的完成度 $C=K+D$ 答案就可以出来了.. 输出的时候除以二 判…
A. CME 题目链接:https://codeforces.com/contest/1241/problem/A 题意: 你有 N 根火柴 , 多少根火柴就可以组成多大的数(如 三根火柴可以表示 3), 现在要求你用火柴组成任意三个数 A , B , C 使得 A + B = C 关系成立 如果无论怎么组都无法使等式成立 , 则你可以额外购入 X 根火柴来重新组数使得关系成立 , 求 X 的最小值 分析: 签到题. 特判 N = 2 , X = 2 当 N > 2 时不难发现当 N 为偶数时是…
目录 Contest Info Solutions A. Save the Nature B. Sequence Sorting C. Paint the Tree D. Stack Exterminable Arrays Contest Info Practice Link Solved A B C D E F 4/6 O O O O - - O 在比赛中通过 Ø 赛后通过 ! 尝试了但是失败了 - 没有尝试 Solutions A. Save the Nature 题意: 有\(n\)个数\…
Virtual participate 的,D题不会做,打了1:30就打不动了,过了ABCE. A - CME 题意:? 题解:? void test_case() { int n; scanf("%d", &n); if(n == 2) puts("2"); else printf("%d\n", n & 1); } B - Strings Equalization 题意:给两个等长的字符串,每次可以把一个字母赋值给它前一个和后…
慢慢来. 题目册 题目 A B C D tag math strings greedy dp 状态 √ √ √ √ //∅,√,× 想法 A. CME res tp A 题意:有\(n\)根火柴,额外填上\(k(k≥0)\)根火柴棍,使得\(n+k\)能分成三份\(a,b,c\),每份至少有一根火柴,满足\(a+b = c\),问\(k\)最小是多少 满足方程 \(a+b+c = n+k\) \(a + b = c\) 得\(2*c = n+k\) 若\(n\)是偶数,那么\(k\)为零,反之\…
D. Nature Reserve 题目链接:https://codeforces.com/contest/1059/problem/D 题意: 在二维坐标平面上给出n个数的点,现在要求一个圆,能够容纳所有的点,并且与x轴相切的最小半径为多少. 题解: 容易知道圆的纵坐标的绝对值等于其半径,并且半径越大,容纳圆的可能性越大,那么就考虑二分其半径,这样y0值也确定了. 但x值不是很好求.这里我们找到y=y0的那一条线,然后根据半径以及y0,yi值,可以求出当x0在哪一段时,能够包含(xi,yi)这…
B - Save the problem! CodeForces - 867B 这个题目还是很简单的,很明显是一个构造题,但是早训的时候脑子有点糊涂,想到了用1 2 来构造, 但是去算这个数的时候算错了... 用1 2 来构造 可以先枚举一些数来找找规律. 1 1 2 2 3 1 1 1    2 1 1 4 .... 可以发现每一个数都是 n/2+1 的可能, 所以反过来推过去就是 (s-1)*2  或者(s-1)*2+1 这个(s-1)*2+1的答案才是正确答案 因为 这个s可以==1 #i…
http://codeforces.com/contest/1059/problem/D 最大值: 最左下方和最右下方分别有一个点 r^2 - (r-1)^2 = (10^7)^2 maxr<0.5*10^14 Way1: 二分. difference: 如果使用 5*10^13 -> 10^-6,2^ 60~70区间,pow,sqrt运算,实测超时. 实际上是,使用. time of a case:-> Code: #include <bits/stdc++.h> usin…
C. Save Energy! time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Julia is going to cook a chicken in the kitchen of her dormitory. To save energy, the stove in the kitchen automatically turn…
传送门 There is a forest that we model as a plane and live nn rare animals. Animal number iihas its lair in the point (xi,yi)(xi,yi). In order to protect them, a decision to build a nature reserve has been made. The reserve must have a form of a circle…
大意:给你一个平面上N(N<=100000)个点,问相切于x轴的圆,将所有的点都覆盖的最小半径是多少. 计算几何???Div2的D题就考计算几何???某人昨天上课才和我们说这种计算几何题看见就溜.... 打完比赛才发现好像并不用计算几何,实则是一个二分答案的水题.. 发现如果点在x轴两侧就肯定不行,所以我们把所有的点都挪到一侧. 我们二分一个半径,然后发现因为圆相切于x轴,那么这个圆的圆心一定在y=r的直线上移动. 对于所有的点,它可以被如图的线段AC上的点覆盖,点在AC下方也同理.(终于有个图…
题意: 给你一个方案数,要求你输出满足该条件的总金额,面值数,和各个面值是多少,答案有多个,随便输出一个即可. Examples Input 18 Output 30 41 5 10 25 Input 3 Output 20 25 2 Input 314 Output 183 46 5 2 139 思路:如果A是1,那么就用1张1元的就好:如果大于1,价格都是2*(A-1),硬币只有1和2,因为,你用(A-1)个2元0个1元,然后是(A-2)个2个1元,这样方案数就相当于A-1减到0,共A种,方…
\(\\\) \(Description\) 你现在有\(N\)个分布在二维平面上的整点\((x_i,y_i)\),现在需要你找到一个圆,满足: 能够覆盖所有的给出点 与\(x\)轴相切 现在需要你确定合法的圆的最小半径是多少,精度误差允许在\(10^{-6}\)范围内. 如果不存在一个合法的圆,输出\(-1​\). \(N\in [1,10^5],x_i,y_i\in [10^{-7},10^7]\) \(\\\) \(Solution\) 垃圾 \(Double\) 毁我青春 首先考虑哪些情…
[链接]h在这里写链接 [题意]     给你一个金额N,和硬币的类型总数M;     (完全背包),然后问你组成N的方案数.     使得,用这些硬币组成价值为N的金额的方案数为A;     现在A已知,让你求出一组合法的N,M以及每个硬币的面值. [题解] 只要面值为1和面值为2. 做个完全背包.就能发现这两个能够覆盖到所有的方案数. [错的次数] 0 [反思] 在这了写反思 [代码] #include <bits/stdc++.h> using namespace std; long l…
题目链接 题目大意: 给你一个有n个元素的数组a,你可以通过一下三种操作使数组的每一个值都为0: 选择一个下标i,然后让a[1],a[2]....a[ i ] 都减一; 选择一个下标i,然后让a[i],a[i+1]....a[n] 都减一; 让每一个值都加一 问让整个数组的值都为0的最小操作数. 题目思路: 我们观察所有操作,发现其都是让一个连续区间都减去一个相同的数,或者加上一个相同的数,这与差分十分相似,所以我们将其转化为差分操作: 1.a[1]-1,a[i+1]+1 2.a[i]-1 3.…
题目链接: http://codeforces.com/problemset/problem/77/C C. Beavermuncher-0xFF time limit per test:3 secondsmemory limit per test:256 megabytes 问题描述 "Eat a beaver, save a tree!" - That will be the motto of ecologists' urgent meeting in Beaverley Hill…
上一次我们拿学校的URP做了个小小的demo.... 其实我们还可以把每个学生的证件照爬下来做成一个证件照校花校草评比 另外也可以写一个物理实验自动选课... 但是出于多种原因,,还是绕开这些敏感话题.. 今天,我们来扒一下cf的题面! PS:本代码不是我原创 1. 必要的分析 1.1 页面的获取 一般情况CF的每一个 contest 是这样的: 对应的URL是:http://codeforces.com/contest/xxx 还有一个Complete problemset页面,它是这样的:…
http://codeforces.com/contest/738/problem/A Polycarp has interviewed Oleg and has written the interview down without punctuation marks and spaces to save time. Thus, the interview is now a string s consisting of n lowercase English letters. There is…
Codeforces Round #354 (Div. 2) Problems     # Name     A Nicholas and Permutation standard input/output 1 s, 256 MB    x3384 B Pyramid of Glasses standard input/output 1 s, 256 MB    x1462 C Vasya and String standard input/output 1 s, 256 MB    x1393…
Codeforces Round #262 (Div. 2) 1003 C. Present time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Little beaver is a beginner programmer, so informatics is his favorite subject. Soon his info…
A. Save Luke 题目连接: http://codeforces.com/contest/624/problem/A Description Luke Skywalker got locked up in a rubbish shredder between two presses. R2D2 is already working on his rescue, but Luke needs to stay alive as long as possible. For simplicity…
B. Ancient Berland Hieroglyphs 题目连接: http://codeforces.com/problemset/problem/164/B Descriptionww.co Polycarpus enjoys studying Berland hieroglyphs. Once Polycarp got hold of two ancient Berland pictures, on each of which was drawn a circle of hierog…
Problem I. Instruction 题目连接: http://codeforces.com/gym/100531/attachments Description Ingrid is a head of a big railway station and, among other duties, is responsible for routing trains to the right platforms. The station has one entrance, and there…
A. New Year and Days 题目连接: http://www.codeforces.com/contest/611/problem/A Description Today is Wednesday, the third day of the week. What's more interesting is that tomorrow is the last day of the year 2015. Limak is a little polar bear. He enjoyed…
A. USB Flash Drives 题目连接: http://www.codeforces.com/contest/609/problem/A Description Sean is trying to save a large file to a USB flash drive. He has n USB flash drives with capacities equal to a1, a2, ..., an megabytes. The file size is equal to m…