-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathPing.cpp
44 lines (38 loc) · 878 Bytes
/
Ping.cpp
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
43
44
#include <bits/stdc++.h>
template<typename T> T gcd(T a, T b) {
if(!b) return a;
return gcd(b, a % b);
}
template<typename T> T lcm(T a, T b) {
return a * b / gcd(a, b);
}
template<typename T> void chmin(T& a, T b) { a = (a > b) ? b : a; }
template<typename T> void chmax(T& a, T b) { a = (a < b) ? b : a; }
int in() { int x; scanf("%d", &x); return x; }
using namespace std;
typedef long long Int;
typedef unsigned uint;
string S;
int main(void) {
while (cin >> S && S != "0") {
vector<int> ans;
for (int i = 1; i < (int) S.size(); i++) {
if (S[i] == '1') {
ans.push_back(i);
for (int j = i; j < (int) S.size(); j += i) {
if (S[j] == '0') {
S[j] = '1';
} else {
S[j] = '0';
}
}
}
}
for (int i = 0; i < (int) ans.size(); i++) {
if (i) cout << " ";
cout << ans[i];
}
cout << "\n";
}
return 0;
}