计蒜客 挑战难题 第20题:跳跃游戏二
来源:互联网 发布:pnp网络摄像机客户端 编辑:程序博客网 时间:2024/05/12 03:36
第20题:跳跃游戏二
仅供参考:
#include <stdio.h>int Jump(int n,int A[]);int Max(int i,int A[],int n);void main(){int A[1000];int n;scanf("%d",&n); for(int i=0;i<n;i++)scanf("%d",&A[i]);printf("%d\n",Jump(n,A));}int Jump(int n,int A[]){ int i=0,sum=A[0],x=0; int count=0; if(1==n) return 0; count++; while(sum<n-1){ count++; if(Max(x,A,sum)>=n-1) return count; else if(Max(x,A,sum)<=sum) break;x=Max(x,A,sum)-sum;sum+=x; } if(sum<n-1) return 0; else return count;}int Max(int i,int A[],int n){int max=0; while(i<=n){ if(max<=A[i]+i&&A[i]!=0)max=A[i]+i;i++; }return max;}
0 0
- 计蒜客 挑战难题 第20题:跳跃游戏二
- 计蒜客 挑战难题 跳跃游戏二
- 计蒜客 挑战难题 第18题:跳跃游戏
- 【计蒜客系列】挑战难题20:跳跃游戏二
- 【计蒜客系列】挑战难题20:跳跃游戏二
- 计蒜客 挑战难题 跳跃游戏
- 【计蒜客系列】挑战难题18:跳跃游戏
- 计蒜客--第20题:跳跃游戏二
- 计蒜客 难题题库 020 跳跃游戏二
- 计蒜客跳跃游戏二
- 计蒜客 跳跃游戏二
- 计蒜客 难题题库 018 跳跃游戏
- 计蒜客 第18题:跳跃游戏
- 计蒜客--第18题:跳跃游戏
- 计蒜客 第18题:跳跃游戏
- 【计蒜客】20 - 跳跃游戏二(dp)
- 第18题:跳跃游戏
- 计蒜客020-跳跃游戏二
- 11076 浮点数的分数表达
- hdu2024
- Codeforces Round #272 (Div. 2)
- error C2061 && error C4430
- Scaling Learning Algorithms towards AI(经典文献阅读)
- 计蒜客 挑战难题 第20题:跳跃游戏二
- Filter
- HDOJ题目4190 Distributing Ballot Boxes(二分搜索)
- Unity3D研究院之在项目中使用Unity4新Mecanim动画
- 【MongoDB】mongoimport and mongoexport of data (二)
- hdu2025
- Ubuntu 嵌入式系统搭建
- 广度优先搜索算法(BFS,Broad First Search)的PHP实现
- MySql命令大全(完整版)