Memory and Scores】的更多相关文章

D. Memory and Scores   Memory and his friend Lexa are competing to get higher score in one popular computer game. Memory starts with score a and Lexa starts with score b. In a single turn, both Memory and Lexa get some integer in the range [ - k;k] (…
Memory and Scores 题目链接:http://codeforces.com/contest/712/problem/D dp 因为每轮Memory和Lexa能取的都在[-k,k],也就是说每轮两人分数的变化量在[-2k,2k]: 故可以定义状态:dp[times][diff]为第times次Memory和Lexa的分数差为diff的方案数. 而dp[times][diff]可以从dp[times-1][diff-2k]到dp[times-1][diff+2k]转移而来: 又因为变化…
D. Memory and Scores 题目连接: http://codeforces.com/contest/712/problem/D Description Memory and his friend Lexa are competing to get higher score in one popular computer game. Memory starts with score a and Lexa starts with score b. In a single turn, b…
[Codeforces712D] Memory and Scores(DP+前缀和优化)(不用单调队列) 题面 两个人玩游戏,共进行t轮,每人每轮从[-k,k]中选出一个数字,将其加到自己的总分中.已知两人的初始得分分别为a和b,求第一个人最后获胜的方案数.两种方案被认为是不同的,当且仅当存在其中一轮,其中一人选到的数字不同.a, b, t≤100,k≤1000 分析 两个人的操作是独立的,设\(dp1[i][j]\)表示第1个人玩i轮得到j分的方案数,第2个人同理 则有\(dp1[0][a]=…
time limit per test2 seconds memory limit per test512 megabytes inputstandard input outputstandard output Memory and his friend Lexa are competing to get higher score in one popular computer game. Memory starts with score a and Lexa starts with score…
题目大意: 两个人玩取数游戏,第一个人分数一开始是a,第二个分数一开始是b,接下来t轮,每轮两人都选择一个[-k,k]范围内的整数,加到自己的分数里,求有多少种情况使得t轮结束后a的分数比b高.  (1 ≤ a, b ≤ 100, 1 ≤ k ≤ 1000, 1 ≤ t ≤ 100) 1.我一开始的想法是DP出玩i轮得分是j的方案数.然后状态数最多有t*(2*k*t)那么多,最坏情况下会有2e7那么多的状态,转移必须是O(1)的. dp[i][j]=sum(dp[i-1][j-k....j+k]…
题目链接:http://codeforces.com/contest/712/problem/D A初始有一个分数a,B初始有一个分数b,有t轮比赛,每次比赛都可以取[-k, k]之间的数,问你最后A比B大的情况有多少种. dpA[i][j]表示第i轮获得j分的情况数.因为第i轮只和第i-1轮有关,所以这里i用滚动数组优化. 要是普通做法3个for就会超时,所以要用前缀和优化,dpA[i][j]可以由一段连续的dp[i - 1][x]转移过来,所以用sumA数组存取dp[i - 1][x]的前缀…
$dp$,前缀和. 记$dp[i][j]$表示$i$轮结束之后,两人差值为$j$的方案数. 转移很容易想到,但是转移的复杂度是$O(2*k)$的,需要优化,观察一下可以发现可以用过前缀和来优化. 我把所有的数组全部开成$long$ $long$超时了,全改成$int$就$AC$了...... #pragma comment(linker, "/STACK:1024000000,1024000000") #include<cstdio> #include<cstring…
dp题 并运用了前缀和 我看题目提示中有fft 我想了下感觉复杂度不过关还是未解 #include<bits/stdc++.h> using namespace std; typedef long long ll; const int MAXN = 4e5+5; const int MOD = 1e9+7; const int ze = 2e5; ll dp[2][MAXN]; ll sum[MAXN]; int main(){ int a,b,k,t; while(~scanf("…
题目分析 实际上两个人轮流取十分鸡肋,可以看作一个人取2t次. 考虑生成函数. 为了方便,我们对取的数向右偏移k位. 取2t次的生成函数为: \[ F(x)=(\sum_{i=0}^{2k}x_i)^{2t} \] 化一下式子: \[ \begin{split} F(x)&=(\frac{1-x^{2k+1}}{1-x})^{2t}\\ &=(1-x^{2k+1})^{2t}\cdot(1-x)^{-2t} \end{split} \] 对两个式子分别二项式展开: \[ \begin{sp…