链接:http://codeforces.com/problemset/problem/669/B

本文链接:http://www.cnblogs.com/Ash-ly/p/5443086.html

题意:

  有个闲的没事干的人找到了一个能跳的小动物,把它放到一个连续的格子中,每个格子都有两个属性,一个是方向">"和"<",分别表示如果到了该格子只能向左(<)跳或者相右跳(>).另外一个属性是能跳多远,比如这个属性是3,那么它到这个格子只能选择往左或者往右跳3步.开始时刻这个小动物在第一个格子,问最后能否调出这个连续的格子,还是永远在这个格子里跳来跳去的循环下去.

思路:

  如果出不去则说明它跳的路径肯定在这些格子里面形成了一个循环节,而出现循环节的原因就是它又回到了某个它曾经走过的地方,所以如果某个格子它跳了两次,那么它肯定出不去了.

代码:

 #include <bits/stdc++.h>
using namespace std; int main()
{
int n;
scanf("%d", &n);
char s[ + ] = {};
scanf("%s", s);
int a[ + ] = {};
for(int i = ; i < n ; i++)
scanf("%d", &a[i]);
int cnt = ;
long long jmp = ;
int flag[] = {};
int ans = ;
int i = ;
while(true)
{
s[i] == '>' ? jmp += a[i] : jmp -= a[i];
if(jmp >= && jmp < n)
{
i = (int)jmp;
if(flag[i] == ) flag[i] = ;
else break;
}
else
{
ans = ;
break;
}
}
if(ans) printf("FINITE\n");
else printf("INFINITE\n");
return ;
}

CodeForces 669B的更多相关文章

  1. codeforces 669B B. Little Artem and Grasshopper(水题)

    题目链接: B. Little Artem and Grasshopper time limit per test 2 seconds memory limit per test 256 megaby ...

  2. python爬虫学习(5) —— 扒一下codeforces题面

    上一次我们拿学校的URP做了个小小的demo.... 其实我们还可以把每个学生的证件照爬下来做成一个证件照校花校草评比 另外也可以写一个物理实验自动选课... 但是出于多种原因,,还是绕开这些敏感话题 ...

  3. 【Codeforces 738D】Sea Battle(贪心)

    http://codeforces.com/contest/738/problem/D Galya is playing one-dimensional Sea Battle on a 1 × n g ...

  4. 【Codeforces 738C】Road to Cinema

    http://codeforces.com/contest/738/problem/C Vasya is currently at a car rental service, and he wants ...

  5. 【Codeforces 738A】Interview with Oleg

    http://codeforces.com/contest/738/problem/A Polycarp has interviewed Oleg and has written the interv ...

  6. CodeForces - 662A Gambling Nim

    http://codeforces.com/problemset/problem/662/A 题目大意: 给定n(n <= 500000)张卡片,每张卡片的两个面都写有数字,每个面都有0.5的概 ...

  7. CodeForces - 274B Zero Tree

    http://codeforces.com/problemset/problem/274/B 题目大意: 给定你一颗树,每个点上有权值. 现在你每次取出这颗树的一颗子树(即点集和边集均是原图的子集的连 ...

  8. CodeForces - 261B Maxim and Restaurant

    http://codeforces.com/problemset/problem/261/B 题目大意:给定n个数a1-an(n<=50,ai<=50),随机打乱后,记Si=a1+a2+a ...

  9. CodeForces - 696B Puzzles

    http://codeforces.com/problemset/problem/696/B 题目大意: 这是一颗有n个点的树,你从根开始游走,每当你第一次到达一个点时,把这个点的权记为(你已经到过不 ...

随机推荐

  1. Codeforces Round #430 (Div. 2) Vitya and Strange Lesson

    D.Vitya and Strange Lesson(字典树) 题意: 给一个长度为\(n\)的非负整数序列,\(m\)次操作,每次先全局异或\(x\),再查询\(mex\) \(1<=n< ...

  2. C++——OOP面向对象理解

    从Rob Pike 的 Google+上的一个推看到了一篇叫<Understanding Object Oriented Programming>的文章,我先把这篇文章简述一下,然后再说说 ...

  3. 【2017.12.22.A】

                                A 题面: 给一个n个点m条边的无向图,你可以选择一个点作为起点,然后沿着图中的边开始走,走的过程中,同一条边不能经过两次(相反的方向也不行). ...

  4. Angular Cookie 读写

    var app = angular.module('Mywind',['ui.router']) app.controller('Myautumn',function($scope,$http,$fi ...

  5. CentOs7 minimal安装后没有ifconfig命令解决方法

    没有ifconfig命令目前我了解两个原因: 1./sbin/ifconfig 可以执行,但是ifconfig无法执行.这个解决的时候只需要将/sbin 添加到PATH下就可以了. 2.系统未安装if ...

  6. codeforces 1015A

    A. Points in Segments time limit per test 1 second memory limit per test 256 megabytes input standar ...

  7. Spring学习--引用其他Bean , 内部Bean

    引用其他Bean: 组成应用程序的 Bean 经常需要相互协作以完成应用程序的功能 , 要使 Bean 能够相互访问, 就必须在 Bean 配置文件中指定对 Bean 的引用. 在 Bean 的配置文 ...

  8. es6+最佳入门实践(10)

    10.Generator 10.1.Generator是什么? Generator函数是ES6提供的一种异步编程解决方案.在它的内部封装了多个状态,因此,又可以理解为一种状态机,执行Generator ...

  9. 【BZOJ1901】Dynamic Rankings [整体二分]

    Dynamic Rankings Time Limit: 10 Sec  Memory Limit: 128 MB[Submit][Status][Discuss] Description 给定一个含 ...

  10. MyBatis系列四 之 智能标签进行查询语句的拼接

    MyBatis系列四 之 智能标签进行查询语句的拼接 使用Foreach进行多条件查询 1.1 foreach使用数组进行多条件查询 在MyBatis的映射文件中进行如下配置 <!--根据数组进 ...