[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 ...
随机推荐
- Spring Boot静态资源
1.4 SpringBoot静态资源 1.4.1 默认静态资源映射 Spring Boot 对静态资源映射提供了默认配置 Spring Boot 默认将 /** 所有访问映射到以下目录: classp ...
- 并行开发 2.task
原文:8天玩转并行开发——第二天 Task的使用 在我们了解Task之前,如果我们要使用多核的功能可能就会自己来开线程,然而这种线程模型在.net 4.0之后被一种称为基于 “任务的编程模型”所冲击, ...
- JavaScript——实现继承的几种方式
实现继承的6中方法: 借用构造函数 组合继承 原型式继承 寄生式继承 寄生组合式继承 拷贝继承 1. 借用构造函数 在子类型构造函数的内部调用超类构造函数.通过使用apply()和call()方法在新 ...
- UIGestureRecognizer 手势
- (void)viewDidLoad { [super viewDidLoad]; // Do any additional setup after loading the view. self.v ...
- 2018-2-13-WPF-延迟加载
title author date CreateTime categories WPF 延迟加载 lindexi 2018-2-13 17:23:3 +0800 2018-2-13 17:23:3 + ...
- linux性能分析工具free
- python时间的获取
一.获取当前时间 import datetime # 2019-7-9 print(datetime.datetime.now().year) # 2019 print(datetime.dateti ...
- Linux就该这么学09学习笔记
参考链接:https://www.linuxprobe.com/chapter-09.html 配置网卡服务 配置网卡参数 1.执行nmtui命令运行网络配置工具 2.选中Edit a connect ...
- kafka2.3集群搭建
环境: 3台centos7.4 3台zookeeper3.4.14 1. wget http://mirror.bit.edu.cn/apache/kafka/2.3.0/kafka_2.11-2.3 ...
- KMP,Trie,AC自动机题目集
字符串算法并不多,KMP,trie,AC自动机就是其中几个最经典的.字符串的题目灵活多变也有许多套路,需要多做题才能体会.这里收集了许多前辈的题目做个集合,方便自己回忆. KMP题目:https:// ...
