[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 ...
随机推荐
- android环境问题
1.android studio bundle和android studio ide区别 android studio bundle和android studio ide区别 准确的说是这三种: 最开 ...
- Spark链接hive时 “HikariCP” 问题
IDE本地调试和spark-shell调试报错: Caused by: org.datanucleus.exceptions.NucleusUserException: The connection ...
- bzoj3270 博物馆(期望+高斯消元)
Time Limit: 30 Sec Memory Limit: 128 MB 有一天Petya和他的朋友Vasya在进行他们众多旅行中的一次旅行,他们决定去参观一座城堡博物馆.这座博物馆有着特别的 ...
- Pull Request的正确打开方式(如何在GitHub上贡献开源项目)
Pull Request的正确打开方式(如何在GitHub上贡献开源项目) GitHub的官方帮助如下: Fork A Repo: https://help.github.com/articles/f ...
- mitdump爬取当当网APP图书目录
因为mitmproxy没办法连接数据库所以,只能先把结果保存为txt文件,再读取到数据库中. 在滑动APP界面时,对代码进行分析 import requests import re import ur ...
- Runtime-iOS运行时应用篇
一.动态方法交换:Method Swizzling实现动态方法交换(Method Swizzling )是Runtime中最具盛名的应用场景,其原理是:通过Runtime获取到方法实现的地址,进而动态 ...
- linux性能分析工具Top
- Linux就该这么学08学习笔记
参考链接:https://www.linuxprobe.com/chapter-08.html 防火墙管理工具 众所周知,相较于企业内网,外部的公网环境更加恶劣,罪恶丛生.在公网与企业内网之间充当保护 ...
- 一、UC中文调试
一.只支持UC浏览器,版本号6.2.3831.3,复制resources.pak到UC安装目录下,覆盖同名文件即可
- bzoj4036 [HAOI2015]按位或 状压DP + MinMax 容斥
题目传送门 https://lydsy.com/JudgeOnline/problem.php?id=4036 题解 变成 \(2^n-1\) 的意思显然就是每一个数位都出现了. 那么通过 MinMa ...
