[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 ...
随机推荐
- LeetCode #938. Range Sum of BST 二叉搜索树的范围和
https://leetcode-cn.com/problems/range-sum-of-bst/ 二叉树中序遍历 二叉搜索树性质:一个节点大于所有其左子树的节点,小于其所有右子树的节点 /** * ...
- 6、numpy——高级索引
NumPy 比一般的 Python 序列提供更多的索引方式.除了之前看到的用整数和切片的索引外,数组可以由整数数组索引.布尔索引及花式索引. 1.整数数组索引 1.1 以下实例获取数组中(0,0),( ...
- 59-python基础-python3-集合-集合常用方法-判断一个集合是否是另一个集合的子集-issubset()-issuperset()
判断一个集合是否是另一个集合的子集-issubset()-issuperset() 1-issubset() s1.issubset(s) 判断s1是否是s的子集 2-issuperset() 与is ...
- HDU Stealing Harry Potter's Precious(状压BFS)
状压BFS 注意在用二维字符数组时,要把空格.换行处理好. #include<stdio.h> #include<algorithm> #include<string.h ...
- textarea实现高度自适应
css部分 #textarea { display: block; margin:0 auto; overflow: hidden; width: 550px; font-size: 14px; he ...
- elasticsearch 深入 —— Scroll滚动查询
Scroll search 请求返回一个单一的结果"页",而 scroll API 可以被用来检索大量的结果(甚至所有的结果),就像在传统数据库中使用的游标 cursor. 滚动并 ...
- rpc - rpc 程序号数据库
SYNOPSIS /etc/rpc DESCRIPTION rpc 文件列出了rpc 程序的可读名, 可以此代替rpc 程序号. 每行包含如下信息: 运行rpc 程序的服务名 rpc 程序号 别名 各 ...
- Codeforces Round #393 (Div. 2) - A
题目链接:http://codeforces.com/contest/760/problem/A 题意:给定一个2017年的月份和该月的第一天的星期,问该月份的日历表中需要多少列.行有7列表示星期一~ ...
- ltp-ddt nand_ecc_tests
NAND_S_FUNC_ECC_2K_BCH8_8ERRS_NO_OOB_ERR source "common.sh"; nandecc_tests.sh -r "0:0 ...
- Ansible用法playbook
playbook文件 hello.yml --- - name: test_tasks [各个任务的总描述] hosts: webserver remote_user: root gather_fac ...
