cf B Inna and Candy Boxes】的更多相关文章

题意:给你一个长度为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…
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…
这个题目看似不是很好下手,不过很容易发现每次询问的时候总是会问到第r个盒子是否有糖果: 这样的话就很好办事了: 维护两个数组: 一个sum数组:累加和: 一个in数组:如果i位是1的话,in[i]=in[i-k]+1;否则不加1,很好理解: 然后利用in数组可以找到本来应该有糖果的但是没有糖果的箱子的数目: 然后结合sum数组就可以的出结果: #include<cstdio> #include<cstring> #define maxn 100005 using namespace…
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…
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…
哎,最近弱爆了,,,不过这题还是不错滴~~ 要考虑完整各种情况 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+…
题目:http://codeforces.com/contest/374/problem/A 题意:求到达边界的最小步数.. 刚开始以为是 bfs,不过数据10^6太大了,肯定不是... 一个思维题,要注意超边界... #include <iostream> #include <cstring> #include <algorithm> using namespace std; <<); int n,m,x,y,a,b; int ok(int x1,int…
http://codeforces.com/contest/374/problem/C 记忆化搜索,题意:求按照要求可以记过名字多少次,如果次数为无穷大,输出Poor Inna!,如果不经过一次输出Poor Dima!,否则输出输出次数. #include <cstdio> #include <cstring> #include <algorithm> #define maxn 1001 #define LL __int64 using namespace std; ;…
http://codeforces.com/contest/374/problem/B #include <cstdio> #include <cstring> #include <algorithm> using namespace std; ]; int main() { while(scanf("%s",str)!=EOF) { int k=strlen(str); __int64 ans=; ; i<k;) { ]-&&…
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…
题目链接: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. Efim and Strange Grade time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Efim just received his grade for the last test. He studies in a special school and his grade can be equal to any po…
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…
Professor GukiZ is concerned about making his way to school, because massive piles of boxes are blocking his way. In total there are n piles of boxes, arranged in a line, from left to right, i-th pile (1 ≤ i ≤ n) containing ai boxes. Luckily, m stude…
[链接]:CF [题意]:对于一个数n,每次加一的代价是a,每次减一的代价是b,求被m整除时的最小代价. [分析]:分情况讨论,自己多举几个栗子. [代码]: #include<cstdio> #include<string> #include<cstdlib> #include<cmath> #include<iostream> #include<cstring> #include<set> #include<qu…
#include <iostream> #include <vector> #include <algorithm> #include <utility> using namespace std; typedef pair<int,int> Point; int n,m; void clockwise_rotate(Point &cell, int x){ ; i < x; ++ i){ int tmp = cell.first;…
http://codeforces.com/problemset/problem/400/C 题意:给你一个n*m的矩阵,然后在矩阵中有p个糖果,给你每个糖果的初始位置,然后经过x次顺时针反转,y次旋转,z次逆时针反转,问最后每个糖果的位置. 思路:推出顺时针反转.旋转.逆时针反转的坐标的变化即可. #include <cstdio> #include <cstring> #include <cmath> #include <iostream> #defin…
题目链接:http://codeforces.com/problemset/problem/400/C 题目意思:给出一个n行m列的矩阵,问经过 x 次clockwise,y 次 horizontal rotate 和z次counterclockwise 之后,原来在n行m列的矩阵的坐标去到哪个位置. 题目意思很容易看懂.易知,对于clockwise,counterclockwise的次数,mod 4 == 0 相当于没有改变!而对于 horizontal rotate,mod 2 == 0 也…
题意:给出一个矩形的三种操作,顺时针旋转,逆时针旋转,对称,给出原始坐标,再给出操作数,问最后得到的坐标 画一下模拟一下操作就可以找到规律了 #include<iostream> #include<cstdio> #include<cstring> #include <cmath> #include<stack> #include<vector> #include<map> #include<set> #inc…
题目链接:http://codeforces.com/problemset/problem/374/A 题目意思:给出一个 n 行  m 列 的棋盘,要将放置在坐标点为(i, j)的 candy 移动到四个角落(1,1),(1,m),(n, 1),(n, m) 中的其中一个.假设当前在位置(x, y),规定每次移动遵循,(x+a, y+b) . (x+a, y-b). (x-a, y+b).(x-a, y-b).求最小的移动次数. 求出 (i, j) 到每个角落的距离diff_x, diff_y…