博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Leetcode 877. 石子游戏(DAY 27) ---- 动态规划学习期
阅读量:1993 次
发布时间:2019-04-27

本文共 624 字,大约阅读时间需要 2 分钟。

原题题目

在这里插入图片描述



代码实现(首刷自解)

bool judge(int* piles,int front,int back,int role,int alexsstone,int lisstone){
if(front != back) {
if(!role) return judge(piles,front+1,back,1,alexsstone+piles[front],lisstone) || judge(piles,front,back-1,1,alexsstone,lisstone+piles[back]); else return judge(piles,front+1,back,0,alexsstone,lisstone+piles[front]) || judge(piles,front,back-1,0,alexsstone+piles[back],lisstone); } else if(lisstone > alexsstone) return true; else return false;}bool stoneGame(int* piles, int pilesSize){
return judge(piles,0,pilesSize-1,0,0,0);}

转载地址:http://yzqvf.baihongyu.com/

你可能感兴趣的文章
LeetCode 887. 鸡蛋掉落
查看>>
第七届acm省赛总结
查看>>
poj 1936 All in All
查看>>
hihocoder 1555 四次方根(矩阵快速幂)
查看>>
codeforces 449 D Jzzhu and Numbers(容斥+dp)
查看>>
Gym - 101334E Exploring Pyramids(dp+分治)
查看>>
hdu 6183 Color it(cdq分治+线段树)
查看>>
atcoder Yet Another Palindrome Partitioning(dp)
查看>>
gym 101137 L Lazy Coordinator(概率)
查看>>
Mysql 入门
查看>>
Vue 之 axios 篇
查看>>
vue 之动画
查看>>
js的基础语法
查看>>
vue使用iconfont
查看>>
linux 查看文件夹权限
查看>>
linux tar 备份
查看>>
ubuntu中配置任意应用的快捷键
查看>>
ln 命令 硬链接
查看>>
chkconfig使用和级别介绍
查看>>
ubuntu 快捷键
查看>>