Program E-- CodeForces 18C】的更多相关文章

Codeforces 18C  C. Stripe 链接:http://acm.hust.edu.cn/vjudge/contest/view.action?cid=86640#problem/E 题目: Description Once Bob took a paper stripe of n squares (the height of the stripe is 1 square). In each square he wrote an integer number, possibly n…
Description Once Bob took a paper stripe of n squares (the height of the stripe is 1 square). In each square he wrote an integer number, possibly negative. He became interested in how many ways exist to cut this stripe into two pieces so that the sum…
Basic Information Publication: ICSE'17 Authors: Shin Hwei Tan, Jooyong Yi, Yulis, Sergey Mechtaev, Abhik Roychoudhury Language: C Program Source: Codeforces Programming Contest (Reject/Accept) Description: a set of 3902 defects from 7436 programs aut…
A. Short Program link http://codeforces.com/contest/878/problem/A describe Petya learned a new programming language CALPAS. A program in this language always takes one non-negative integer and returns one non-negative integer as well. In the language…
题目链接:http://codeforces.com/contest/879/problem/C C. Short Program time limit per test2 seconds memory limit per test256 megabytes Petya learned a new programming language CALPAS. A program in this language always takes one non-negative integer and re…
题目链接:http://codeforces.com/contest/283/problem/B 思路: dp[now][flag]表示现在在位置now,flag表示是接下来要做的步骤,然后根据题意记忆化搜索记忆,vis数组标记那些已经访问过的状态. #include <iostream> #include <cstdio> #include <cstring> #include <algorithm> #define REP(i, a, b) for (i…
C. Short Program time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Petya learned a new programming language CALPAS. A program in this language always takes one non-negative integer and retur…
传送门:http://codeforces.com/contest/879/problem/C 本题是一个位运算问题——位运算的等价变换. 假设位运算符“&”“|”“^”是左结合的,且优先级相同,则一个表达式:“x@a[1]@a[2]@...@a[n]”,等价于“(...((x@a[1])@a[2])...)@a[n]”.其中,“@”为位运算符“&”“|”“^”. 将表达式“x@a[1]@a[2]@...@a[n]”表示为一个简单的等价形式:“((x&a)|b)^c”,即“x&am…
题目链接:http://codeforces.com/contest/284/problem/D 题意:给出n个数,奇数次操作x,y都加上a[x],偶数次操作y加上a[x],x减去a[x],走出了范围就结束. 问结束时的y值,如果无法结束,那么输出-1 题解:很显然可以用记忆化搜索来解决,可以设dp[i][j](i=0表示偶数次操作以j为结尾的y值是多少,i=1表示奇数次操作以j为结尾的y值是多少) 在加一个辅助的vis[i][j](i=0表示偶数次操作以j为结尾有没有取过,i=1表示奇数次操作…
原题链接:http://codeforces.com/problemset/problem/878/A 题意:给出n个位运算操作, 化简这些操作, 使化简后的操作次数不多于5步. 思路:我们可以对二进制每一位上的1, 0, 进行讨论, 如果n次操作后1 -->1, 0 --> 1, 说明这一位要用或操作(or 1) 类似的,1 -->0, 0 -->1, 说明这一位要用异或操作(xor 1)        1 -->0, 0 -->0, 说明这一位要用与操作(and 0…