Voracious Steve 题目连接: http://codeforces.com/gym/100231/attachments Description 有两个人在玩一个游戏 有一个盆子里面有n个甜甜圈,A先开始,他可以抓[1,min(m,n)]颗甜甜圈,然后B开始,同样,可以抓[1,min(n,m)]个甜甜圈 谁抓完的,就可以把自己抓的吃完,然后另外一个人就把他的甜甜圈扔进去,然后由失败的那个人开始 问你第一个人最多能吃到多少个甜甜圈 Input 2个整数 n,m 表示一开始有n个甜甜圈,…
题目链接:http://codeforces.com/problemset/problem/900/D 题意: 给定x,y,问你有多少个数列a满足gcd(a[i]) = x 且 ∑(a[i]) = y. 题解: 由于gcd(a[i]) = x,所以y一定是x的倍数,否则无解. 那么原题就等价于:问你有多少个数列a满足gcd(a[i]) = 1 且 ∑(a[i]) = y/x. 设f(k)为gcd(a[i]) = 1 且 ∑(a[i]) = k时的答案. 只满足条件∑(a[i]) = k的数列共有…
题意:我方有n个士兵,敌方有m个,每方士兵都有一个血量,现在有k轮无差别炮火打击,每次都会从存活的士兵中随机选一人,这名士兵的HP就-1,问对方被团灭的概率有多大? 思路:因为n和m的范围很小,我们可以考虑暴力搜索,中间使用记忆化.这里状态压缩有一个小技巧,我们的正常想法是:因为士兵总数最多只有10个,我们可以用一个十位数来表示状态,每一位数代表这个士兵的现在的HP.但是我这样设计状态超时了...网上的状态设置的比较巧妙,网上用了12位数来表示状态,每一位代表敌方或者我方的HP为某个值的士兵还剩…
题目链接:Playing Piano 题意:给定长度为n的序列$a_i$,要求得到同样长度的序列$b_i$.满足一下条件: if $a_i < a_{i+1}$ then $b_i < b_{i+1}$ if $a_i > a_{i+1}$ then $b_i > b_{i+1}$ if $a_i = a_{i+1}$ then $b_i \neq\ b_{i+1}$ $1 <= b_i <= 5$ 题解:第一个数从1-5枚举,接着从下一位开始搜索,dp[i][j]表示…
题意及思路:https://blog.csdn.net/bossup/article/details/37076965 代码: #include <bits/stdc++.h> #define LL long long #define INF 1e18 using namespace std; int lcm(int x, int y) { return x * y / __gcd(x, y); } const int maxn = 500010; LL a, b, k; LL dp[maxn…
E. Explosion Exploit time limit per test 2.0 s memory limit per test 256 MB input standard input output standard output In a two player card game, you have nn minions on the board and the opponent has mm minions. Each minion has a health between 11 a…
Spiral Maximum 题目连接: http://codeforces.com/problemset/problem/173/C Description Let's consider a k × k square, divided into unit squares. Please note that k ≥ 3 and is odd. We'll paint squares starting from the upper left square in the following orde…
D. Zuma 题目连接: http://www.codeforces.com/contest/608/problem/D Description Genos recently installed the game Zuma on his phone. In Zuma there exists a line of n gemstones, the i-th of which has color ci. The goal of the game is to destroy all the gems…
E. Chocolate Bar Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/598/problem/E Description You have a rectangular chocolate bar consisting of n × m single squares. You want to eat exactly k squares, so you may need to break…
题目:http://codeforces.com/contest/398/problem/B 有点似曾相识的感觉,记忆中上次那个跟这个相似的 我是用了 暴力搜索过掉的,今天这个肯定不行了,dp方程想了非常久也没有想出来,有点无从下手的感觉,最后还是尝试了一下记忆化搜索,以dp[0][0]为边界,dp[x][y]代表当前有x行y列没有彩色的 瓷砖,搜索起来思路还是非常清晰的,可惜最后那个 算期望公式给写错了,瞎了好久,做出以后看了一下别人的做法,确实有点难想到,把涂好的都放在右下角,这样就仅仅有四…