zoukankan      html  css  js  c++  java
  • JSK 18: 跳跃游戏

    #include <iostream>
    #include <string>
    #include <cstdio>
    #include <cmath>
    #include <cstring>
    #include <algorithm>
    #include <vector>
    #include <queue>
    #include <deque>
    #include <map>
    #define range(i,a,b) for(int i=a;i<=b;++i)
    #define LL long long
    #define rerange(i,a,b) for(int i=a;i>=b;--i)
    #define fill(arr,tmp) memset(arr,tmp,sizeof(arr))
    using namespace std;
    int n,num[505],dp[505];
    void init() {
        cin>>n;
        range(i,0,n-1)cin>>num[i];
    }
    void solve(){
        bool ans=false;
        if(n==1)ans=true;
        int pos=0;
        while(pos<n-1){
            pos+=num[pos];
            if(!num[pos]&&pos!=n-1)break;
            if(pos==n-1){ans=true;break;}
        }
        cout<<(ans?"true":"false")<<endl;
    }
    int main() {
        init();
        solve();
        return 0;
    }
    View Code
  • 相关阅读:
    Delphi制作带图标的弹出式选单 DELPHI
    在DBGrid中实现Copy、Paste功能 DELPHI
    使用stringgrid的例子 DELPHI
    取得某一dll所有输出函数名 DELPHI
    HDOJ 2512 一卡通大冒险
    POJ 2533 Longest Ordered Subsequence
    UVA 10795 A Different Task
    HDOJ 1505 City Game
    HDOJ 1864 最大报销额
    HDOJ 1421 搬寝室
  • 原文地址:https://www.cnblogs.com/Rhythm-/p/9336648.html
Copyright © 2011-2022 走看看