您的位置:首页 > 其它

Codeforces New Year Transportation

2017-06-21 09:56 369 查看
题目链接:http://codeforces.com/problemset/problem/500/A

import java.util.Scanner;

public class NewYearTransportation {

public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
int n = scanner.nextInt();
int t = scanner.nextInt();
int[] a = new int
;
for(int i = 1; i < n; i++) {
a[i] = i + scanner.nextInt();
}
int j = 1;
while(j < n) {
if(a[j] == t) {
System.out.println("YES");
return ;
}
j = a[j];
}
System.out.println("NO");
}
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: