Codeforces 488B - Candy Boxes】的更多相关文章

B. Candy Boxes 题目链接:http://codeforces.com/problemset/problem/488/B time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output There is an old tradition of keeping 4 boxes of candies in the house in Cy…
B. Candy Boxes Problem's Link:   http://codeforces.com/contest/488/problem/B Mean: T题目意思很简单,不解释. analyse: 这道题还是很有意思的,需要考虑到各种情况才能AC. 解这个题目之前,首先要推出两条式子 x4=3x1 4x1=x2+x3 然后就是分类讨论,枚举各种情况就可. Time complexity: O(1) Source code:  // Memory Time // 1347K 0MS…
C. Inna and Candy Boxes   Inna loves sweets very much. She has n closed present boxes lines up in a row in front of her. Each of these boxes contains either a candy (Dima's work) or nothing (Sereja's work). Let's assume that the boxes are numbered fr…
哎,最近弱爆了,,,不过这题还是不错滴~~ 要考虑完整各种情况 8795058                 2014-11-22 06:52:58     njczy2010     B - Candy Boxes             GNU C++     Accepted 31 ms 4 KB 8795016                 2014-11-22 06:48:15     njczy2010     B - Candy Boxes             GNU C+…
这个题目看似不是很好下手,不过很容易发现每次询问的时候总是会问到第r个盒子是否有糖果: 这样的话就很好办事了: 维护两个数组: 一个sum数组:累加和: 一个in数组:如果i位是1的话,in[i]=in[i-k]+1;否则不加1,很好理解: 然后利用in数组可以找到本来应该有糖果的但是没有糖果的箱子的数目: 然后结合sum数组就可以的出结果: #include<cstdio> #include<cstring> #define maxn 100005 using namespace…
D. Boxes And Balls time limit per test2 seconds memory limit per test256 megabytes 题目链接:http://codeforces.com/contest/884/problem/D Description Ivan has n different boxes. The first of them contains some balls of n different colors. Ivan wants to pla…
题目链接:http://codeforces.com/contest/334/problem/A 题意:有n个人,将1-n袋(第 i  袋共有 i  颗糖果,1<= i  <=n)所有的糖果(n*(n+1)/2)均分到n个人中. 这里要注意的是输出问题,每行中的前n / 2(包括n/2)个数比较容易解决,就是每两个数中相隔n个长度,第n/2个数和第n/2+1个数之间隔了多少个长度,这是值得考虑的问题.我的做法是,由于每个人分到的糖果是 (n / 2) * (n*n+1)  (输出的n个数看成n…
Link: Codeforces 1053C 传送门 Solution: 先推出一个结论: 最后必有一个点不动且其为权值上最中间的一个点 证明用反证证出如果不在中间的点必有一段能用代价少的替代多的 这样问题转换为求出区间第一个大于权值和一半的点,并求结果 如果只考虑半边的结果为$\sum_{i=1}^{mid} (pos[mid]-pos[i]-(mid-i))*w[i]$ 将$pos[i]$修改为$pos[i]-i$之后维护$\sum pos[i]*w[i]$的和即可 以上操作可以用两颗线段树…
忘了是偶数了,在纸上画奇数画了半天... #include<cstdio> #include<cstring> #include<cstdlib> #include<cmath> #include<algorithm> using namespace std; #define LL __int64 ]; int main() { int n,i,j,tot; scanf("%d",&n); j=; ;i<n;i+…
题意:给你一个长度为n的只含有1和0的字符串,w个询问,每次询问输入l,r:在[l,r]中在l+k-1.l+2*k-1.......r的位置都必须为1,如果不为1的,变成1,记为一次操作,其它的地方的都必须为0,不为0的地方要变成1,也记为一次操作,最后问在区间[l,r]最少几次操作. 思路:可以用树状数组记录在某个地方的右方有多少个1,然后在 预处理出从1,2,..k的为开头的在i+c*k-1的位置上前面有多少个1,最后的答案是拿走的1+添加的1,拿走的1的个数等于现有的1的个数-位置正确的1…
题意:输入n,然后输入n个数ai,再输入n个数bi,如果在1-ai中能找到两个数x,y,x和y可以相等,如果x+y=bi,答案加上x*y,否则减去1,让结果尽可能大,输出结果. #include <cstdio> #include <cstring> #include <algorithm> #define ll long long #define maxn 100100 using namespace std; int n; ll a[maxn],b[maxn]; i…
原文链接https://www.cnblogs.com/zhouzhendong/p/CF1053C.html 题目传送门 - CF1053C 题意 有 $n$ 个物品,第 $i$ 个物品在位置 $a_i$ ,重量为 $w_i$ .使得重量为 $x$ 的物品移动一单位距离的花费是 $x$ .接下来 $q$ 个操作,有两种类型: 1. 将物品 $i$ 的重量修改成 $nw$ . 2. 询问把区间 $[L,R]$ 内的物品都移动到一段连续的区间 $[x,x+R-L]$ 内,并且互不重叠,相对顺序保持…
传送门 就是让你维护动态的区间带权中位数. 然而昨晚比赛时并没有调出来. 想找到带权中位数的中点可以二分(也可以直接在线段树上找). 也就是二分出第一个断点,使得断点左边的和恰好大于或等于断点右边的和. 现在的问题在于知道断点之后如何统计答案. 我们可以在线段树中维护当前区间全部移到区间最左端点的花费,以及当前区间全部移到区间最右端点的花费. 这样就可以简单合并并轻松统计答案了. 代码: #include<bits/stdc++.h> #define ll long long #define…
我们考虑前缀和sum[i],如果将a[i+1]中的一个塞入a[i]中,则不影响sum[i+1],但是sum[i]++,如果将a[i]中的一个塞入a[i+1],则不影响sum[i+1],但是sum[i]--,我们可以发现操作一次相当于将一个sum[i]+1或者到sum[i]-1,那么题意就变成了操作多少次可以使得所有的sum[i]为某一个k的倍数,那么一个sum[i]变成k的倍数操作次数最小必然为min(sum[i]%k,k-sum[i]%k),那么接下如何考虑k呢,显然k是sum[n]的一个因子…
题目链接:http://codeforces.com/contest/488 A. Giga Tower Giga Tower is the tallest and deepest building in Cyberland. There are 17 777 777 777 floors, numbered from  - 8 888 888 888 to 8 888 888 888. In particular, there is floor 0 between floor  - 1 and…
C. Inna and Candy Boxes time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Inna loves sweets very much. She has n closed present boxes lines up in a row in front of her. Each of these boxes co…
Candy Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 3069    Accepted Submission(s): 1415Special Judge Problem Description LazyChild is a lazy child who likes candy very much. Despite being ver…
LazyChild is a lazy child who likes candy very much. Despite being very young, he has two large candy boxes, each contains n candies initially. Everyday he chooses one box and open it. He chooses the first box with probability p and the second box wi…
B - Candy Time Limit:1000MS     Memory Limit:32768KB     64bit IO Format:%I64d & %I64u Submit Status Practice HDU 4465 Appoint description:  System Crawler  (2014-10-17) Description LazyChild is a lazy child who likes candy very much. Despite being v…
1639 - Candy Time limit: 3.000 seconds 1639 CandyLazyChild is a lazy child who likes candy very much. Despite being very young, he has two large candy boxes, each contains n candies initially. Everyday he chooses one box and open it. He chooses the fi…
Jessie and Justin want to participate in e-sports. E-sports contain many games, but they don't know which one to choose, so they use a way to make decisions. They have several boxes of candies, and there are ii candies in the i^{th}i th box, each can…
LazyChild is a lazy child who likes candy very much. Despite being very young, he has two large candy boxes, each contains n candies initially. Everyday he chooses one box and open it. He chooses the first box with probability p and the second box wi…
这场打得还是比较爽的,但是队友差一点就再过一题,还是难受啊. 每天都有新的难过 A. Magic Mirror Jessie has a magic mirror. Every morning she will ask the mirror: 'Mirror mirror tell me, who is the most beautiful girl in the world?' If the mirror says her name, she will praise the mirror: '…
Participate in E-sports 11.44% 1000ms 65536K   Jessie and Justin want to participate in e-sports. E-sports contain many games, but they don't know which one to choose, so they use a way to make decisions. They have several boxes of candies, and there…
Jessie and Justin want to participate in e-sports. E-sports contain many games, but they don't know which one to choose, so they use a way to make decisions. They have several boxes of candies, and there are ii candies in the i^{th}ith box, each cand…
在焦作站的acm网络赛中遇到了一个高精度开根的水题--但是那时候WA了 后面学写java补题还T了orz 所以写一篇文章来记录一下java的大整数类型的基础和开根还有一点心得体会吧 首先给那一题的题面和模板 Jessie and Justin want to participate in e-sports. E-sports contain many games, but they don't know which one to choose, so they use a way to make…
C. GukiZ hates Boxes Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/551/problem/C Description Professor GukiZ is concerned about making his way to school, because massive piles of boxes are blocking his way. In total there…
Codeforces Educational Codeforces Round 44 (Rated for Div. 2) E. Pencils and Boxes 题目连接: http://codeforces.com/contest/985/problem/E Description Mishka received a gift of multicolored pencils for his birthday! Unfortunately he lives in a monochrome w…
题目链接:http://codeforces.com/problemset/problem/551/C time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Professor GukiZ is concerned about making his way to school, because massive piles of bo…
http://codeforces.com/contest/1066/problem/D Maksim has nn objects and mm boxes, each box has size exactly kk. Objects are numbered from 11 to nn in order from left to right, the size of the ii-th object is aiai. Maksim wants to pack his objects into…