[Codeforces 729F] Financiers Game
#include<bits/stdc++.h>
using namespace std;
#define getsum(l,r) (sum[r] - sum[l-1])
int n;
],sum[];
int Hash(int a,int b,int c,int d){
+c)*+d) %();
}
int dfs(int x,int y,int k,int now){
< k);
== k):);
int num = Hash(x,y,k,now);
if(~dp[num])return dp[num];
;
if(now){
ans = dfs(x,y-k,k,) - getsum(y-k+,y);
,k+,)-getsum(y-k,y));
return dp[num] = ans;
}
else{
ans = dfs(x + k,y,k,)+getsum(x,x+k-);
,y,k+,)+getsum(x,x+k));
return dp[num] = ans;
}
}
int main(){
ios::sync_with_stdio();
cin>>n;
memset(dp,-,sizeof(dp));
;i<=n;++i)cin>>sum[i],sum[i] += sum[i-];
cout<<dfs(,n,,);
;
}
[Codeforces 729F] Financiers Game的更多相关文章
- Codeforces Round #380 Div.2 F - Financiers Game
F - Financiers Game 这种两人博弈一般都可以用两个dp写, 一个dp描述第一个人的最优态, 第二个dp描述第二个人的最优态,难点在于优化空间... 我感觉这个空间开得有点玄学.. d ...
- Financiers Game CodeForces - 737D (博弈论)
直接暴力区间DP的话是$O(n^3)$, 关键注意到每步走的距离差不超过1, 所以差最大是$O(\sqrt{n})$的, 所以实际上有用的状态是$O(n^2)$的, 可以通过.
- python爬虫学习(5) —— 扒一下codeforces题面
上一次我们拿学校的URP做了个小小的demo.... 其实我们还可以把每个学生的证件照爬下来做成一个证件照校花校草评比 另外也可以写一个物理实验自动选课... 但是出于多种原因,,还是绕开这些敏感话题 ...
- 【Codeforces 738D】Sea Battle(贪心)
http://codeforces.com/contest/738/problem/D Galya is playing one-dimensional Sea Battle on a 1 × n g ...
- 【Codeforces 738C】Road to Cinema
http://codeforces.com/contest/738/problem/C Vasya is currently at a car rental service, and he wants ...
- 【Codeforces 738A】Interview with Oleg
http://codeforces.com/contest/738/problem/A Polycarp has interviewed Oleg and has written the interv ...
- CodeForces - 662A Gambling Nim
http://codeforces.com/problemset/problem/662/A 题目大意: 给定n(n <= 500000)张卡片,每张卡片的两个面都写有数字,每个面都有0.5的概 ...
- CodeForces - 274B Zero Tree
http://codeforces.com/problemset/problem/274/B 题目大意: 给定你一颗树,每个点上有权值. 现在你每次取出这颗树的一颗子树(即点集和边集均是原图的子集的连 ...
- CodeForces - 261B Maxim and Restaurant
http://codeforces.com/problemset/problem/261/B 题目大意:给定n个数a1-an(n<=50,ai<=50),随机打乱后,记Si=a1+a2+a ...
随机推荐
- Junit测试错误:### Error building SqlSession
错误代码: org.apache.ibatis.exceptions.PersistenceException: ### Error building SqlSession.### The error ...
- FireFox浏览器导出文件名乱码
解决方案1 String codedFileName = "导出文件名.xls"; String agent = request.getHeader("USER-AGEN ...
- Webpack的使用指南-Webpack的常用解决方案
说是解决方案实际上更像是webpack的插件索引. 写这一篇的目的是为了形成一个所以,将来要用时直接来查找即可. 1.自动构建HTML,可压缩空格,可给引用的js加版本号或随机数:html-webpa ...
- RMQ(鸽巢原理或字符串操作)
http://acm.hdu.edu.cn/showproblem.php?pid=3183 A Magic Lamp Time Limit: 2000/1000 MS (Java/Others) ...
- #python# error:http.client.RemoteDisconnected: Remote end closed connection without response
添加headers user-agent 网络情况不好的状态下也能出现
- ajax_封装函数_升级_传递多个参数和传递一个参数
HTML: <!DOCTYPE html> <html lang="zh-CN"> <head> <meta charset=" ...
- 解决图片插入word文档后清晰度降低的问题
解决图片插入word文档后清晰度降低的问题 在默认情况下,word程序会自动压缩插入word文档中的图片以减小整个word文档的.当我们需要插入word文档中的图片保持原始清晰度时,可以通过设置wor ...
- 牛客小白月赛16 D 小阳买水果 (思维题)
链接:https://ac.nowcoder.com/acm/contest/949/D来源:牛客网 时间限制:C/C++ 1秒,其他语言2秒 空间限制:C/C++ 262144K,其他语言52428 ...
- 开源安全:PE分析
https://github.com/JusticeRage/Manalyze.git https://github.com/JusticeRage/Manalyze https://www.free ...
- 牛客网NOIP赛前集训营-提高组(第六场)B-选择题
题目描述 有一道选择题,有 a,b,c,d 四个选项. 现在有 n 个人来做这题,第 i 个人有 pi,j 的概率选第 j 个选项. 定义\(cnt(x)\)为选第$ x $个选项的人数. 令\(mx ...
