-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpetr_book.java
42 lines (40 loc) · 1.24 KB
/
petr_book.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
//Problem: https://codeforces.com/contest/139/problem/A
import java.io.*;
import java.util.*;
public class petr_book {
static BufferedReader br;
static PrintWriter out;
static StringTokenizer st = new StringTokenizer("");
static int T = 1;
public static void main(String[] args) throws IOException {
br = new BufferedReader(new InputStreamReader(System.in));
// br = new BufferedReader(new FileReader("main.dat"));
out = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));
// T = nexti();
for (int tt = 1; tt <= T; tt++) {
int n = nexti();
int[] a = new int[7];
for (int i = 0; i < 7; i++) a[i] = nexti();
int i = 0;
while(n > 0) {
n -= a[i];
i = ++i % 7;
}
out.println(i == 0 ? 7 : i);
}
br.close(); out.close();
}
static String next() throws IOException{
while(!st.hasMoreTokens()) st = new StringTokenizer(br.readLine());
return st.nextToken();
}
static int nexti() throws IOException {
return Integer.parseInt(next());
}
static long nextl() throws IOException {
return Long.parseLong(next());
}
static double nextd() throws IOException {
return Double.parseDouble(next());
}
}