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");
}
}
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");
}
}
相关文章推荐
- Codeforces Round #100//140C - New Year Snowmen C. New Year Snowmen
- Codeforces Round #100 A. New Year Table
- I - New Year and Rating CodeForces - 750C 模拟
- D - New Year Table CodeForces - 140A——double精度+弧度角度转化
- D - New Year Table CodeForces - 140A
- Educational Codeforces Round 6 E. New Year Tree(DFS序+线段树)
- Codeforces Round #456 Div.2 B. New Year's Eve
- E - New Year Cards CodeForces - 140B
- New Year Transportation(CoderForces A)
- C - New Year and Hurry CodeForces - 750A(动态规划)
- New Year and Curling CodeForces - 908C
- The New Year: Meeting Friends Codeforces Round#375-A
- Educational Codeforces Round 6 E. New Year Tree(dfs序线段树)
- A - New Year Table CodeForces - 140A(精度,几何图形)
- New Year Tree CodeForces - 620E
- E - New Year and North Pole CodeForces - 750B(状态处理下就好了)
- New Year and Rating CodeForces - 750C
- codeforces New Year Santa Network
- 【Educational Codeforces Round 6E】【线段树 dfs序】New Year Tree 子树颜色修改子树颜色数
- Codeforces Round #100 (Div. 2) A - New Year Table