ping/Ping_artur.java
1 import java.io.BufferedReader;
2 import java.io.InputStreamReader;
3
4 public class Ping_artur {
5
6 public static void main(String[] args) throws Exception {
7 BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
8 for (String s = in.readLine(); !"0".equals(s); s = in.readLine()) {
9 char[] a = s.toCharArray();
10 boolean first = true;
11 for (int i = 1; i < a.length; i++)
12 if (a[i] == '1') {
13 System.out.print((first ? "" : " ") + i);
14 first = false;
15 for (int j = i; j < a.length; j += i)
16 a[j] = (char) ('1' - a[j] + '0');
17 }
18 System.out.println();
19 }
20 }
21 }