Datasets:

problem_id
stringlengths
6
6
buggy_code
stringlengths
8
526k
fixed_code
stringlengths
12
526k
labels
listlengths
0
15
buggy_submission_id
int64
1
1.54M
fixed_submission_id
int64
2
1.54M
user_id
stringlengths
10
10
language
stringclasses
9 values
p02972
#include <algorithm> #include <cmath> #include <cstdio> #include <deque> #include <functional> #include <iostream> #include <map> #include <queue> #include <set> #include <string> #include <unordered_map> using namespace std; typedef long long ll; #define FOR(i, a, b) for (int i = (a); i < (b); ++i) #define REP(i, n) for (int i = 0; i < (n); ++i) int main(int argc, char **argv) { int N; cin >> N; int a[N]; REP(i, N) cin >> a[i]; int b[N]; for (int i = N; i >= 1; --i) { int s = a[i - 1]; int itr = i * 2; while (itr <= N) { s ^= b[itr - 1]; itr *= 2; } b[i - 1] = s; } int c = 0; REP(i, N) { if (b[i] == 1) c++; } cout << c << endl; if (c > 0) { c = 0; REP(i, N) { if (b[i] == 1) { if (c == 0) cout << (i + 1); else cout << " " << (i + 1); c++; } } cout << endl; } return 0; }
#include <algorithm> #include <cmath> #include <cstdio> #include <deque> #include <functional> #include <iostream> #include <map> #include <queue> #include <set> #include <string> #include <unordered_map> using namespace std; typedef long long ll; #define FOR(i, a, b) for (int i = (a); i < (b); ++i) #define REP(i, n) for (int i = 0; i < (n); ++i) int main(int argc, char **argv) { int N; cin >> N; int a[N]; REP(i, N) cin >> a[i]; int b[N]; for (int i = N; i >= 1; --i) { int s = a[i - 1]; int itr = i * 2; while (itr <= N) { s ^= b[itr - 1]; itr += i; } b[i - 1] = s; } int c = 0; REP(i, N) { if (b[i] == 1) c++; } cout << c << endl; if (c > 0) { c = 0; REP(i, N) { if (b[i] == 1) { if (c == 0) cout << (i + 1); else cout << " " << (i + 1); c++; } } cout << endl; } return 0; }
[ "assignment.change" ]
777,886
777,887
u001534842
cpp
p02972
#include <algorithm> #include <cmath> #include <cstdio> #include <deque> #include <functional> #include <iostream> #include <map> #include <queue> #include <set> #include <string> #include <unordered_map> using namespace std; typedef long long ll; #define FOR(i, a, b) for (int i = (a); i < (b); ++i) #define REP(i, n) for (int i = 0; i < (n); ++i) int main(int argc, char **argv) { int N; cin >> N; int a[N]; REP(i, N) cin >> a[i]; int b[N]; for (int i = N; i >= 1; --i) { int s = a[i - 1]; int itr = i * 2; while (itr < N) { s ^= b[itr - 1]; itr *= 2; } b[i - 1] = s; } int c = 0; REP(i, N) { if (b[i] == 1) c++; } cout << c << endl; if (c > 0) { c = 0; REP(i, N) { if (b[i] == 1) { if (c == 0) cout << (i + 1); else cout << " " << (i + 1); c++; } } cout << endl; } return 0; }
#include <algorithm> #include <cmath> #include <cstdio> #include <deque> #include <functional> #include <iostream> #include <map> #include <queue> #include <set> #include <string> #include <unordered_map> using namespace std; typedef long long ll; #define FOR(i, a, b) for (int i = (a); i < (b); ++i) #define REP(i, n) for (int i = 0; i < (n); ++i) int main(int argc, char **argv) { int N; cin >> N; int a[N]; REP(i, N) cin >> a[i]; int b[N]; for (int i = N; i >= 1; --i) { int s = a[i - 1]; int itr = i * 2; while (itr <= N) { s ^= b[itr - 1]; itr += i; } b[i - 1] = s; } int c = 0; REP(i, N) { if (b[i] == 1) c++; } cout << c << endl; if (c > 0) { c = 0; REP(i, N) { if (b[i] == 1) { if (c == 0) cout << (i + 1); else cout << " " << (i + 1); c++; } } cout << endl; } return 0; }
[ "expression.operator.compare.change", "control_flow.loop.condition.change", "assignment.change" ]
777,888
777,887
u001534842
cpp
p02972
#include <algorithm> #include <cmath> #include <cstdio> #include <deque> #include <functional> #include <iostream> #include <map> #include <queue> #include <set> #include <string> #include <unordered_map> using namespace std; typedef long long ll; #define FOR(i, a, b) for (int i = (a); i < (b); ++i) #define REP(i, n) for (int i = 0; i < (n); ++i) int main(int argc, char **argv) { int N; cin >> N; int a[N]; REP(i, N) cin >> a[i]; int b[N]; for (int i = N; i >= 1; --i) { int s = a[i - 1]; int itr = i * 2; while (itr < N) { s ^= a[itr - 1]; itr *= 2; } b[i - 1] = s; } int c = 0; REP(i, N) { if (b[i] == 1) c++; } cout << c << endl; if (c > 0) { c = 0; REP(i, N) { if (b[i] == 1) { if (c == 0) cout << (i + 1); else cout << " " << (i + 1); c++; } } cout << endl; } return 0; }
#include <algorithm> #include <cmath> #include <cstdio> #include <deque> #include <functional> #include <iostream> #include <map> #include <queue> #include <set> #include <string> #include <unordered_map> using namespace std; typedef long long ll; #define FOR(i, a, b) for (int i = (a); i < (b); ++i) #define REP(i, n) for (int i = 0; i < (n); ++i) int main(int argc, char **argv) { int N; cin >> N; int a[N]; REP(i, N) cin >> a[i]; int b[N]; for (int i = N; i >= 1; --i) { int s = a[i - 1]; int itr = i * 2; while (itr <= N) { s ^= b[itr - 1]; itr += i; } b[i - 1] = s; } int c = 0; REP(i, N) { if (b[i] == 1) c++; } cout << c << endl; if (c > 0) { c = 0; REP(i, N) { if (b[i] == 1) { if (c == 0) cout << (i + 1); else cout << " " << (i + 1); c++; } } cout << endl; } return 0; }
[ "expression.operator.compare.change", "control_flow.loop.condition.change", "assignment.value.change", "identifier.change", "assignment.change" ]
777,889
777,887
u001534842
cpp
p02972
#include <algorithm> #include <cmath> #include <deque> #include <iomanip> #include <iostream> #include <map> #include <queue> #include <set> #include <vector> #define rep(i, n) for (int i = 0; i < (n); i++) using namespace std; typedef long long ll; const int mod = 1e9 + 7; const int inf = 1 << 30; typedef pair<int, int> P; int main() { int n; cin >> n; vector<int> a(n + 1); rep(i, n) cin >> a[i + 1]; vector<int> b(n + 1); for (int i = n; i >= 1; i--) { int sum = 0; for (int j = i + i; j < n; j += i) { sum ^= b[j]; } b[i] = sum ^ a[i]; } vector<int> ans; for (int i = 1; i <= n; i++) { if (b[i]) ans.push_back(i); } cout << ans.size() << endl; rep(i, ans.size()) { if (i) cout << " "; cout << ans[i]; if (i == ans.size() - 1) cout << endl; } return 0; }
#include <algorithm> #include <cmath> #include <deque> #include <iomanip> #include <iostream> #include <map> #include <queue> #include <set> #include <vector> #define rep(i, n) for (int i = 0; i < (n); i++) using namespace std; typedef long long ll; const int mod = 1e9 + 7; const int inf = 1 << 30; typedef pair<int, int> P; int main() { int n; cin >> n; vector<int> a(n + 1); rep(i, n) cin >> a[i + 1]; vector<int> b(n + 1); for (int i = n; i >= 1; i--) { int sum = 0; for (int j = i + i; j <= n; j += i) { sum ^= b[j]; } b[i] = sum ^ a[i]; } vector<int> ans; for (int i = 1; i <= n; i++) { if (b[i]) ans.push_back(i); } cout << ans.size() << endl; rep(i, ans.size()) { if (i) cout << " "; cout << ans[i]; if (i == ans.size() - 1) cout << endl; } return 0; }
[ "expression.operator.compare.change", "control_flow.loop.for.condition.change", "expression.off_by_one", "expression.operation.binary.change" ]
777,890
777,891
u013803727
cpp
p02972
#include <algorithm> #include <cmath> #include <deque> #include <iomanip> #include <iostream> #include <map> #include <queue> #include <set> #include <vector> #define rep(i, n) for (int i = 0; i < (n); i++) using namespace std; typedef long long ll; const int mod = 1e9 + 7; const int inf = 1 << 30; typedef pair<int, int> P; int main() { int n; cin >> n; vector<int> a(n + 1); rep(i, n) cin >> a[i + 1]; vector<int> b(n + 1); for (int i = n; i >= 1; i--) { int sum = 0; for (int j = i + i; j < n; j += i) { sum ^= a[j]; } b[i] = sum ^ a[i]; } vector<int> ans; for (int i = 1; i <= n; i++) { if (b[i]) ans.push_back(i); } cout << ans.size() << endl; rep(i, ans.size()) { if (i) cout << " "; cout << ans[i]; if (i == ans.size() - 1) cout << endl; } return 0; }
#include <algorithm> #include <cmath> #include <deque> #include <iomanip> #include <iostream> #include <map> #include <queue> #include <set> #include <vector> #define rep(i, n) for (int i = 0; i < (n); i++) using namespace std; typedef long long ll; const int mod = 1e9 + 7; const int inf = 1 << 30; typedef pair<int, int> P; int main() { int n; cin >> n; vector<int> a(n + 1); rep(i, n) cin >> a[i + 1]; vector<int> b(n + 1); for (int i = n; i >= 1; i--) { int sum = 0; for (int j = i + i; j <= n; j += i) { sum ^= b[j]; } b[i] = sum ^ a[i]; } vector<int> ans; for (int i = 1; i <= n; i++) { if (b[i]) ans.push_back(i); } cout << ans.size() << endl; rep(i, ans.size()) { if (i) cout << " "; cout << ans[i]; if (i == ans.size() - 1) cout << endl; } return 0; }
[ "expression.operator.compare.change", "control_flow.loop.for.condition.change", "expression.off_by_one", "expression.operation.binary.change", "assignment.value.change", "identifier.change" ]
777,892
777,891
u013803727
cpp
p02972
#include <bits/stdc++.h> #include <cmath> #include <map> #define rep(i, n) for (int(i) = 0; (i) < (n); (i)++) #define rep2(i, a, n) for (int i = a; i < n; i++) #define been(ix) (ix).begin(), (ix).end() using namespace std; typedef long long ll; typedef vector<int> vi; typedef vector<long long> vl; const ll INFL = 1e18; const int INF = 1001001001; typedef pair<int, int> P; #define foreach(ix, i) for (auto &(ix) : (i)) typedef long double ld; const ll max_co = 3234600000; vl ans; int mod = 1000000007; int main() { int n; cin >> n; vi a(n + 1), res(n + 1, -1), ans; int m; rep(i, n) { cin >> a[i + 1]; } for (int i = n; i >= 1; i--) { int d = 0; for (int j = 2; j <= n / i; j++) { if (res[i * j] == 1) d++; } if (d % 2 != a[i]) { res[i] = 1; m++; ans.push_back(i); } } cout << m + 1 << endl; for (int x : ans) { cout << x << ' '; } cout << endl; }
#include <bits/stdc++.h> #include <cmath> #include <map> #define rep(i, n) for (int(i) = 0; (i) < (n); (i)++) #define rep2(i, a, n) for (int i = a; i < n; i++) #define been(ix) (ix).begin(), (ix).end() using namespace std; typedef long long ll; typedef vector<int> vi; typedef vector<long long> vl; const ll INFL = 1e18; const int INF = 1001001001; typedef pair<int, int> P; #define foreach(ix, i) for (auto &(ix) : (i)) typedef long double ld; const ll max_co = 3234600000; vl ans; int mod = 1000000007; int main() { int n; cin >> n; vi a(n + 1), res(n + 1, -1), ans; int m = 0; rep(i, n) { cin >> a[i + 1]; } for (int i = n; i >= 1; i--) { int d = 0; for (int j = 2; j <= n / i; j++) { if (res[i * j] == 1) d++; } if (d % 2 != a[i]) { res[i] = 1; m++; ans.push_back(i); } } cout << m << endl; for (int x : ans) { cout << x << ' '; } cout << endl; }
[ "variable_declaration.value.change", "expression.operation.binary.remove" ]
777,905
777,904
u495881622
cpp
p02972
#include <bits/stdc++.h> #include <cmath> #include <map> #define rep(i, n) for (int(i) = 0; (i) < (n); (i)++) #define rep2(i, a, n) for (int i = a; i < n; i++) #define been(ix) (ix).begin(), (ix).end() using namespace std; typedef long long ll; typedef vector<int> vi; typedef vector<long long> vl; const ll INFL = 1e18; const int INF = 1001001001; typedef pair<int, int> P; #define foreach(ix, i) for (auto &(ix) : (i)) typedef long double ld; const ll max_co = 3234600000; vl ans; int mod = 1000000007; int main() { int n; cin >> n; vi a(n + 1), res(n + 1, -1), ans; int m = 0; rep(i, n) { cin >> a[i + 1]; } for (int i = n; i >= 1; i--) { int d = 0; for (int j = 2; j <= n / i; j++) { if (res[i * j - 1] == 1) d++; } if (d % 2 != a[i]) { res[i] = 1; m++; ans.push_back(i); } } cout << m << endl; for (int x : ans) { cout << x << ' '; } cout << endl; }
#include <bits/stdc++.h> #include <cmath> #include <map> #define rep(i, n) for (int(i) = 0; (i) < (n); (i)++) #define rep2(i, a, n) for (int i = a; i < n; i++) #define been(ix) (ix).begin(), (ix).end() using namespace std; typedef long long ll; typedef vector<int> vi; typedef vector<long long> vl; const ll INFL = 1e18; const int INF = 1001001001; typedef pair<int, int> P; #define foreach(ix, i) for (auto &(ix) : (i)) typedef long double ld; const ll max_co = 3234600000; vl ans; int mod = 1000000007; int main() { int n; cin >> n; vi a(n + 1), res(n + 1, -1), ans; int m = 0; rep(i, n) { cin >> a[i + 1]; } for (int i = n; i >= 1; i--) { int d = 0; for (int j = 2; j <= n / i; j++) { if (res[i * j] == 1) d++; } if (d % 2 != a[i]) { res[i] = 1; m++; ans.push_back(i); } } cout << m << endl; for (int x : ans) { cout << x << ' '; } cout << endl; }
[ "control_flow.loop.for.condition.change", "expression.operation.binary.remove" ]
777,906
777,904
u495881622
cpp
p02972
#include <iostream> #include <vector> using namespace std; int main() { int n; cin >> n; vector<int> a(n + 1), b(n + 1); for (int i = 1; i <= n; i++) { cin >> a[i]; } int m = 0; for (int i = n; i >= 1; i--) { int tempi = i * 2; int sum = 0; while (tempi <= n) { sum += b[tempi]; tempi += i; } b[i] = (sum + a[i]) % 2; m += b[i]; } cout << m << endl; for (int i = 1; i <= m; i++) { if (b[i]) { cout << i << ' '; } } cout << endl; return 0; }
#include <iostream> #include <vector> using namespace std; int main() { int n; cin >> n; vector<int> a(n + 1), b(n + 1); for (int i = 1; i <= n; i++) { cin >> a[i]; } int m = 0; for (int i = n; i >= 1; i--) { int tempi = i * 2; int sum = 0; while (tempi <= n) { sum += b[tempi]; tempi += i; } b[i] = (sum + a[i]) % 2; m += b[i]; } cout << m << endl; for (int i = 1; i <= n; i++) { if (b[i]) { cout << i << ' '; } } cout << endl; return 0; }
[ "identifier.change", "control_flow.loop.for.condition.change", "expression.operation.binary.change" ]
777,911
777,912
u342703951
cpp
p02972
#include <algorithm> #include <cctype> #include <cmath> #include <cstdio> #include <cstdlib> #include <iostream> #include <list> #include <map> #include <queue> #include <set> #include <stack> #include <string> #include <vector> using namespace std; int main() { int n, a[200001] = {}; cin >> n; for (int i = 1; i <= n; i++) { cin >> a[i]; } int b[200001] = {}; for (int i = n; i > 0; i--) { int s = 0; for (int j = 2; j <= n / i; j++) { s += b[i * j]; } b[i] = (s + a[i]) % 2; } int cnt = 0; for (int i = 0; i < n; i++) { cnt += b[i]; } cout << cnt << endl; for (int i = 1; i <= n; i++) { if (b[i] == 1) cout << i << " "; } cout << endl; }
#include <algorithm> #include <cctype> #include <cmath> #include <cstdio> #include <cstdlib> #include <iostream> #include <list> #include <map> #include <queue> #include <set> #include <stack> #include <string> #include <vector> using namespace std; int main() { int n, a[200001] = {}; cin >> n; for (int i = 1; i <= n; i++) { cin >> a[i]; } int b[200001] = {}; for (int i = n; i > 0; i--) { int s = 0; for (int j = 2; j <= n / i; j++) { s += b[i * j]; } b[i] = (s + a[i]) % 2; } int cnt = 0; for (int i = 1; i <= n; i++) { cnt += b[i]; } cout << cnt << endl; for (int i = 1; i <= n; i++) { if (b[i] == 1) cout << i << " "; } cout << endl; }
[ "literal.number.change", "variable_declaration.value.change", "control_flow.loop.for.initializer.change", "expression.off_by_one", "expression.operator.compare.change", "control_flow.loop.for.condition.change", "expression.operation.binary.change" ]
777,913
777,914
u120050685
cpp
p02972
#include <algorithm> #include <cctype> #include <cmath> #include <cstdio> #include <cstdlib> #include <iostream> #include <list> #include <map> #include <queue> #include <set> #include <stack> #include <string> #include <vector> using namespace std; int main() { int n, a[200001] = {}; cin >> n; for (int i = 1; i <= n; i++) { cin >> a[i]; } int b[200001] = {}; for (int i = n; i > 0; i--) { int s = 0; for (int j = 2; j <= n / i; j++) { s += b[i * j]; } b[i] = (s + a[i]) % 2; } int cnt = 0; for (int i = 0; i < n; i++) { cnt += b[i]; } cout << cnt; for (int i = 1; i <= n; i++) { if (b[i] == 1) cout << i << " "; } cout << endl; }
#include <algorithm> #include <cctype> #include <cmath> #include <cstdio> #include <cstdlib> #include <iostream> #include <list> #include <map> #include <queue> #include <set> #include <stack> #include <string> #include <vector> using namespace std; int main() { int n, a[200001] = {}; cin >> n; for (int i = 1; i <= n; i++) { cin >> a[i]; } int b[200001] = {}; for (int i = n; i > 0; i--) { int s = 0; for (int j = 2; j <= n / i; j++) { s += b[i * j]; } b[i] = (s + a[i]) % 2; } int cnt = 0; for (int i = 1; i <= n; i++) { cnt += b[i]; } cout << cnt << endl; for (int i = 1; i <= n; i++) { if (b[i] == 1) cout << i << " "; } cout << endl; }
[ "literal.number.change", "variable_declaration.value.change", "control_flow.loop.for.initializer.change", "expression.off_by_one", "expression.operator.compare.change", "control_flow.loop.for.condition.change", "expression.operation.binary.change", "io.output.newline.add" ]
777,915
777,914
u120050685
cpp
p02972
#include <algorithm> #include <bitset> #include <cassert> #include <chrono> #include <cmath> #include <complex> #include <cstdio> #include <cstring> #include <ctime> #include <fstream> #include <functional> #include <iomanip> #include <iostream> #include <map> #include <numeric> #include <queue> #include <random> #include <set> #include <string> #include <unordered_map> #include <unordered_set> #include <vector> using namespace std; signed main() { ios_base::sync_with_stdio(false); cin.tie(0); int n; cin >> n; vector<int> a(n + 1); for (int i = 1; i <= n; i++) { cin >> a[i]; } vector<int> b(n + 1); for (int i = n; i > 0; i--) { int c = 0; for (int j = 2 * i; j <= n; j += i) { c ^= b[j]; } b[i] = (c ^ a[i]); } vector<int> tk; for (int i = 1; i <= n; i++) { if (b[i]) tk.push_back(i); } cout << tk.size() << endl; for (auto t : tk) { cout << t + 1 << ' '; } cout << endl; }
#include <algorithm> #include <bitset> #include <cassert> #include <chrono> #include <cmath> #include <complex> #include <cstdio> #include <cstring> #include <ctime> #include <fstream> #include <functional> #include <iomanip> #include <iostream> #include <map> #include <numeric> #include <queue> #include <random> #include <set> #include <string> #include <unordered_map> #include <unordered_set> #include <vector> using namespace std; signed main() { ios_base::sync_with_stdio(false); cin.tie(0); int n; cin >> n; vector<int> a(n + 1); for (int i = 1; i <= n; i++) { cin >> a[i]; } vector<int> b(n + 1); for (int i = n; i > 0; i--) { int c = 0; for (int j = 2 * i; j <= n; j += i) { c ^= b[j]; } b[i] = (c ^ a[i]); } vector<int> tk; for (int i = 1; i <= n; i++) { if (b[i]) tk.push_back(i); } cout << tk.size() << endl; for (auto t : tk) { cout << t << ' '; } cout << endl; }
[ "expression.operation.binary.remove" ]
777,916
777,917
u293523151
cpp
p02972
#include <algorithm> #include <assert.h> #include <bitset> #include <cstdio> #include <cstring> #include <iomanip> #include <iostream> #include <map> #include <math.h> #include <queue> #include <set> #include <vector> // #include<bits/stdc++.h> using namespace std; typedef long long ll; constexpr long long int INFLL = 1001001001001001LL; constexpr long long int infll = 1001001001001001LL; constexpr int INF = 1000000007; constexpr int inf = 1000000007; const int mod = 1000000007; template <class T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; } template <class T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; } ll gcd(ll a, ll b) { if (a % b == 0) { return (b); } else { return (gcd(b, a % b)); } } ll lcm(ll a, ll b) { return a / gcd(a, b) * b; } template <typename T> T seinomi(T a) { if (a > 0) { return a; } else { return 0; } } //連想配列[素因数f.first][個数f.second] template <typename T> map<T, T> soinsuubunkai(T n) { map<T, T> ret; for (T i = 2; i * i <= n; i++) { while (n % i == 0) { ret[i]++; n /= i; } } if (n != 1) ret[n] = 1; return ret; } //桁数取得 template <typename T> T ketasuu(T num) { return std::to_string(num).length(); } //階乗 ll kaizyou(ll k) { ll sum = 1; for (ll i = 1; i <= k; ++i) { sum *= i; } return sum; } //階乗を(10^9)+7で割った余り ll modkaizyou(ll k) { ll sum = 1; for (int i = 1; i <= k; ++i) { sum *= i; sum = sum % mod; } return sum; } template <class ForwardIt, class T> void iota(ForwardIt first, ForwardIt last, T value) { while (first != last) { *first++ = value; ++value; } } //整数乗 int llpow(ll a, ll n) { // aのn乗を計算します。 ll x = 1; while (n > 0) { //全てのbitが捨てられるまで。 if (n & 1) { // 1番右のbitが1のとき。 x = x * a; } a = a * a; n >>= 1; // bit全体を右に1つシフトして一番右を捨てる。 } return x; } long long modpow(long long a, long long n, long long mod) { long long res = 1; while (n > 0) { if (n & 1) res = res * a % mod; a = a * a % mod; n >>= 1; } return res; } template <typename T> T amarinasi(T a, T b) { if (a % b == 0) { return a / b; } else if (a % b > 0) { return a / b + 1; } else { return a / b - 1; } } //組み合わせ nCr void nCr_Calculater(vector<vector<long long int>> &v) { for (int i = 0; i < v.size(); i++) { v[i][0] = 1; v[i][i] = 1; } for (int k = 1; k < v.size(); k++) { for (int j = 1; j < k; j++) { v[k][j] = (v[k - 1][j - 1] + v[k - 1][j]); } } } ll nCr(ll N, ll K) { vector<vector<long long int>> v(N + 1, vector<long long int>(N + 1, 0)); nCr_Calculater(v); return v[N][K]; } // 組み合わせnCrを1000000007で割った余り void COMinit(vector<ll> &fac, vector<ll> &finv, vector<ll> &inv) { fac[0] = fac[1] = 1; finv[0] = finv[1] = 1; inv[1] = 1; for (int i = 2; i < 1000010; i++) { fac[i] = fac[i - 1] * i % mod; inv[i] = mod - inv[mod % i] * (mod / i) % mod; finv[i] = finv[i - 1] * inv[i] % mod; } } long long COM(int n, int k, vector<ll> &fac, vector<ll> &finv, vector<ll> &inv) { if (n < k) return 0; if (n < 0 || k < 0) return 0; return fac[n] * (finv[k] * finv[n - k] % mod) % mod; } ll modnCr(ll n, ll r) { vector<ll> fac(1000010), finv(1000010), inv(1000010); COMinit(fac, finv, inv); return COM(n, r, fac, finv, inv); } //順列 nPr ll nPr(ll n, ll r) { r = n - r; ll sum = 1; ll i; for (i = n; i >= r + 1; i--) sum *= i; return sum; } //重複組み合わせ nHr = (r+n-1)Cr ll nHr(ll n, ll r) { return nCr(r + n - 1, r); } //弧度法から度数法に変換 double to_deg(double r) { return r * 180.0 / (atan(1.0) * 4.0); } //座標から度数法の角度に変換 double kakudo(double dx, double dy) { return atan2(dx, dy) * 180.0 / (atan(1.0) * 4.0); } //約数列挙配列(1を必ず含むことに注意) vector<ll> yakusuu(ll n) { vector<ll> ret; for (ll i = 1; i * i <= n; i++) { if (n % i == 0) { ret.push_back(i); if (i * i != n) ret.push_back(n / i); } } sort(begin(ret), end(ret)); return (ret); } //素数判定bool型配列 std::vector<bool> sosuuhantei(ll max) { vector<bool> ret; if (max + 1 > ret.size()) { // resizeで要素数が減らないように ret.resize(max + 1, true); // IsPrimeに必要な要素数を確保 } ret[0] = false; // 0は素数ではない ret[1] = false; // 1は素数ではない for (ll i = 2; i * i <= max; ++i) { // 0からsqrt(max)まで調べる if (ret[i]) { // iが素数ならば for (ll j = 2; i * j <= max; ++j) { // (max以下の)iの倍数は ret[i * j] = false; // 素数ではない } } } return (ret); } //素数列挙longlong型配列 std::vector<ll> sosuurekkyo(ll max) { vector<bool> tmp; vector<ll> ret; if (max + 1 > tmp.size()) { // resizeで要素数が減らないように tmp.resize(max + 1, true); // IsPrimeに必要な要素数を確保 } tmp[0] = false; // 0は素数ではない tmp[1] = false; // 1は素数ではない for (ll i = 2; i * i <= max; ++i) { // 0からsqrt(max)まで調べる if (tmp[i]) { // iが素数ならば for (ll j = 2; i * j <= max; ++j) { // (max以下の)iの倍数は tmp[i * j] = false; // 素数ではない } } } for (ll i = 0; i <= max; i++) { if (tmp[i]) { ret.push_back(i); } } return (ret); } //小数点以下10桁テンプレート(main関数内の最初に貼付け) // std::cout << std::fixed << std::setprecision(10); //---------------------------------------------------------------- int main() { ll n; cin >> n; bool a[n]; for (ll i = 0; i < n; i++) { cin >> a[i]; } for (ll i = n - 1; i >= 0; i--) { if (a[i] == 1) { for (auto f : yakusuu(i + 1)) { if (f != 1 && f != i + 1) { a[f - 1] = !a[f - 1]; } } } } ll sum = 0; for (auto f : a) { if (f) { sum++; } } cout << sum << endl; for (ll i = 0; i < n; i++) { if (a[i] == 1) { cout << i + 1 << " "; } } }
#include <algorithm> #include <assert.h> #include <bitset> #include <cstdio> #include <cstring> #include <iomanip> #include <iostream> #include <map> #include <math.h> #include <queue> #include <set> #include <vector> // #include<bits/stdc++.h> using namespace std; typedef long long ll; constexpr long long int INFLL = 1001001001001001LL; constexpr long long int infll = 1001001001001001LL; constexpr int INF = 1000000007; constexpr int inf = 1000000007; const int mod = 1000000007; template <class T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; } template <class T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; } ll gcd(ll a, ll b) { if (a % b == 0) { return (b); } else { return (gcd(b, a % b)); } } ll lcm(ll a, ll b) { return a / gcd(a, b) * b; } template <typename T> T seinomi(T a) { if (a > 0) { return a; } else { return 0; } } //連想配列[素因数f.first][個数f.second] template <typename T> map<T, T> soinsuubunkai(T n) { map<T, T> ret; for (T i = 2; i * i <= n; i++) { while (n % i == 0) { ret[i]++; n /= i; } } if (n != 1) ret[n] = 1; return ret; } //桁数取得 template <typename T> T ketasuu(T num) { return std::to_string(num).length(); } //階乗 ll kaizyou(ll k) { ll sum = 1; for (ll i = 1; i <= k; ++i) { sum *= i; } return sum; } //階乗を(10^9)+7で割った余り ll modkaizyou(ll k) { ll sum = 1; for (int i = 1; i <= k; ++i) { sum *= i; sum = sum % mod; } return sum; } template <class ForwardIt, class T> void iota(ForwardIt first, ForwardIt last, T value) { while (first != last) { *first++ = value; ++value; } } //整数乗 int llpow(ll a, ll n) { // aのn乗を計算します。 ll x = 1; while (n > 0) { //全てのbitが捨てられるまで。 if (n & 1) { // 1番右のbitが1のとき。 x = x * a; } a = a * a; n >>= 1; // bit全体を右に1つシフトして一番右を捨てる。 } return x; } long long modpow(long long a, long long n, long long mod) { long long res = 1; while (n > 0) { if (n & 1) res = res * a % mod; a = a * a % mod; n >>= 1; } return res; } template <typename T> T amarinasi(T a, T b) { if (a % b == 0) { return a / b; } else if (a % b > 0) { return a / b + 1; } else { return a / b - 1; } } //組み合わせ nCr void nCr_Calculater(vector<vector<long long int>> &v) { for (int i = 0; i < v.size(); i++) { v[i][0] = 1; v[i][i] = 1; } for (int k = 1; k < v.size(); k++) { for (int j = 1; j < k; j++) { v[k][j] = (v[k - 1][j - 1] + v[k - 1][j]); } } } ll nCr(ll N, ll K) { vector<vector<long long int>> v(N + 1, vector<long long int>(N + 1, 0)); nCr_Calculater(v); return v[N][K]; } // 組み合わせnCrを1000000007で割った余り void COMinit(vector<ll> &fac, vector<ll> &finv, vector<ll> &inv) { fac[0] = fac[1] = 1; finv[0] = finv[1] = 1; inv[1] = 1; for (int i = 2; i < 1000010; i++) { fac[i] = fac[i - 1] * i % mod; inv[i] = mod - inv[mod % i] * (mod / i) % mod; finv[i] = finv[i - 1] * inv[i] % mod; } } long long COM(int n, int k, vector<ll> &fac, vector<ll> &finv, vector<ll> &inv) { if (n < k) return 0; if (n < 0 || k < 0) return 0; return fac[n] * (finv[k] * finv[n - k] % mod) % mod; } ll modnCr(ll n, ll r) { vector<ll> fac(1000010), finv(1000010), inv(1000010); COMinit(fac, finv, inv); return COM(n, r, fac, finv, inv); } //順列 nPr ll nPr(ll n, ll r) { r = n - r; ll sum = 1; ll i; for (i = n; i >= r + 1; i--) sum *= i; return sum; } //重複組み合わせ nHr = (r+n-1)Cr ll nHr(ll n, ll r) { return nCr(r + n - 1, r); } //弧度法から度数法に変換 double to_deg(double r) { return r * 180.0 / (atan(1.0) * 4.0); } //座標から度数法の角度に変換 double kakudo(double dx, double dy) { return atan2(dx, dy) * 180.0 / (atan(1.0) * 4.0); } //約数列挙配列(1を必ず含むことに注意) vector<ll> yakusuu(ll n) { vector<ll> ret; for (ll i = 1; i * i <= n; i++) { if (n % i == 0) { ret.push_back(i); if (i * i != n) ret.push_back(n / i); } } sort(begin(ret), end(ret)); return (ret); } //素数判定bool型配列 std::vector<bool> sosuuhantei(ll max) { vector<bool> ret; if (max + 1 > ret.size()) { // resizeで要素数が減らないように ret.resize(max + 1, true); // IsPrimeに必要な要素数を確保 } ret[0] = false; // 0は素数ではない ret[1] = false; // 1は素数ではない for (ll i = 2; i * i <= max; ++i) { // 0からsqrt(max)まで調べる if (ret[i]) { // iが素数ならば for (ll j = 2; i * j <= max; ++j) { // (max以下の)iの倍数は ret[i * j] = false; // 素数ではない } } } return (ret); } //素数列挙longlong型配列 std::vector<ll> sosuurekkyo(ll max) { vector<bool> tmp; vector<ll> ret; if (max + 1 > tmp.size()) { // resizeで要素数が減らないように tmp.resize(max + 1, true); // IsPrimeに必要な要素数を確保 } tmp[0] = false; // 0は素数ではない tmp[1] = false; // 1は素数ではない for (ll i = 2; i * i <= max; ++i) { // 0からsqrt(max)まで調べる if (tmp[i]) { // iが素数ならば for (ll j = 2; i * j <= max; ++j) { // (max以下の)iの倍数は tmp[i * j] = false; // 素数ではない } } } for (ll i = 0; i <= max; i++) { if (tmp[i]) { ret.push_back(i); } } return (ret); } //小数点以下10桁テンプレート(main関数内の最初に貼付け) // std::cout << std::fixed << std::setprecision(10); //---------------------------------------------------------------- int main() { ll n; cin >> n; bool a[n]; for (ll i = 0; i < n; i++) { cin >> a[i]; } for (ll i = n - 1; i >= 0; i--) { if (a[i] == 1) { for (auto f : yakusuu(i + 1)) { if (f != i + 1) { a[f - 1] = !a[f - 1]; } } } } ll sum = 0; for (auto f : a) { if (f) { sum++; } } cout << sum << endl; for (ll i = 0; i < n; i++) { if (a[i] == 1) { cout << i + 1 << " "; } } }
[ "control_flow.loop.for.condition.change", "expression.operation.binary.remove" ]
777,926
777,927
u863537799
cpp
p02972
#include <bits/stdc++.h> using namespace std; template <typename T, typename U> bool chmin(T &a, const U &b) { return (a > b ? a = b, true : false); } template <typename T, typename U> bool chmax(T &a, const U &b) { return (a < b ? a = b, true : false); } typedef long long ll; #define writeln(n) cout << n << "\n"; typedef pair<int, int> P; typedef pair<string, int> Psi; int main() { cin.tie(0); ios::sync_with_stdio(false); int n; cin >> n; vector<int> a(n + 1); for (int i = 0; i < n; i++) { cin >> a[i + 1]; } vector<int> b(n + 1); for (int i = n; i >= 1; --i) { int sum = 0; for (int j = i + i; j <= n; j += i) { sum ^= b[j]; } b[i] = sum ^ a[i]; } vector<int> ans; for (int i = 1; i < n; i++) { if (b[i]) ans.push_back(i); } cout << ans.size() << endl; for (int i = 0; i < ans.size(); i++) { printf("%d%c", ans[i], i + 1 == ans.size() ? '\n' : ' '); } }
#include <bits/stdc++.h> using namespace std; template <typename T, typename U> bool chmin(T &a, const U &b) { return (a > b ? a = b, true : false); } template <typename T, typename U> bool chmax(T &a, const U &b) { return (a < b ? a = b, true : false); } typedef long long ll; #define writeln(n) cout << n << "\n"; typedef pair<int, int> P; typedef pair<string, int> Psi; int main() { cin.tie(0); ios::sync_with_stdio(false); int n; cin >> n; vector<int> a(n + 1); for (int i = 0; i < n; i++) { cin >> a[i + 1]; } vector<int> b(n + 1); for (int i = n; i >= 1; --i) { int sum = 0; for (int j = i + i; j <= n; j += i) { sum ^= b[j]; } b[i] = sum ^ a[i]; } vector<int> ans; for (int i = 1; i <= n; i++) { if (b[i]) ans.push_back(i); } cout << ans.size() << endl; for (int i = 0; i < ans.size(); i++) { printf("%d%c", ans[i], i + 1 == ans.size() ? '\n' : ' '); } }
[ "expression.operator.compare.change", "control_flow.loop.for.condition.change", "expression.off_by_one", "expression.operation.binary.change" ]
777,934
777,935
u020238108
cpp
p02972
#include <bits/stdc++.h> using namespace std; typedef int64_t ll; typedef long double ld; const ll MOD = 1000000007; #define rep(i, n) for (ll i = 0; i < (ll)(n); i++) long long gcd(long long a, long long b) { ll gcdmax = max(a, b); ll gcdmin = min(a, b); while (true) { if (gcdmax % gcdmin == 0) break; else gcdmax %= gcdmin; swap(gcdmin, gcdmax); } return gcdmin; } ll powerup(ll N, ll P, ll M) { if (P == 0) return 1; else if (P % 2 == 0) { ll t = powerup(N, P / 2, M); return t * t % M; } else return N * powerup(N, P - 1, M) % M; } int main() { ll N; cin >> N; ll M = 0; ll C = 0; vector<ll> A(N + 1); rep(i, N) cin >> A.at(i + 1); for (ll i = N; i >= 1; i--) { C = 0; for (ll j = 1; j <= N / i; j++) { C = (C + A.at(j)) % 2; } A.at(i) = C; if (C == 1) M++; } cout << M << endl; rep(i, N) { if (A.at(i + 1) == 1) cout << i + 1 << " "; } }
#include <bits/stdc++.h> using namespace std; typedef int64_t ll; typedef long double ld; const ll MOD = 1000000007; #define rep(i, n) for (ll i = 0; i < (ll)(n); i++) long long gcd(long long a, long long b) { ll gcdmax = max(a, b); ll gcdmin = min(a, b); while (true) { if (gcdmax % gcdmin == 0) break; else gcdmax %= gcdmin; swap(gcdmin, gcdmax); } return gcdmin; } ll powerup(ll N, ll P, ll M) { if (P == 0) return 1; else if (P % 2 == 0) { ll t = powerup(N, P / 2, M); return t * t % M; } else return N * powerup(N, P - 1, M) % M; } int main() { ll N; cin >> N; ll M = 0; ll C = 0; vector<ll> A(N + 1); rep(i, N) cin >> A.at(i + 1); for (ll i = N; i >= 1; i--) { C = 0; for (ll j = 1; j <= N / i; j++) { C = (C + A.at(j * i)) % 2; } A.at(i) = C; if (C == 1) M++; } cout << M << endl; rep(i, N) { if (A.at(i + 1) == 1) cout << i + 1 << " "; } }
[ "assignment.change" ]
777,938
777,939
u288905450
cpp
p02972
#include <algorithm> #include <array> #include <cmath> #include <complex> #include <cstdio> #include <deque> #include <float.h> #include <functional> #include <iomanip> #include <iostream> #include <limits.h> #include <list> #include <map> #include <numeric> #include <queue> #include <set> #include <sstream> #include <stack> #include <stdio.h> #include <string.h> #include <string> #include <tuple> #include <unordered_map> #include <vector> using namespace std; #define int long long #define I32_MAX 2147483647 #define I64_MAX 9223372036854775807LL #define I64_MAX2 1223372036854775807LL #define INF I64_MAX2 #define MOD 1000000007 #define MEM_SIZE 10000 #define DEBUG_OUT true #define ALL(x) (x).begin(), (x).end() // int DP[MEM_SIZE][MEM_SIZE] = {0}; // int GMEM[MEM_SIZE][MEM_SIZE] = {0}; template <typename T> void DEBUG(T e) { if (DEBUG_OUT == false) return; std::cout << e << std::endl; } template <typename T> void DEBUG(const std::vector<T> &v) { if (DEBUG_OUT == false) return; for (const auto &e : v) { std::cout << e << " "; } std::cout << std::endl; } template <typename T> void DEBUG(const std::vector<std::vector<T>> &vv) { if (DEBUG_OUT == false) return; for (const auto &v : vv) { DEBUG(v); } } template <class T, class X> void DEBUG(X d, T e) { if (DEBUG_OUT == false) return; std::cout << d << " "; DEBUG(e); }; template <class T> void corner(bool flg, T hoge) { if (flg) { cout << hoge << endl; exit(0); } } template <typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); } template <typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); } template <typename T> using matrix = vector<vector<T>>; vector<int> divisor(int n) { vector<int> ret; for (int i = 1; i * i <= n; i++) { if (n % i == 0) { ret.push_back(i); if (i * i != n) ret.push_back(n / i); } } sort(begin(ret), end(ret)); return (ret); } // FUNCTION void solve(void) { int N; cin >> N; vector<int> vec(N + 1); for (int i = 0; i < N; i++) { cin >> vec[i + 1]; } vector<int> ANS(N + 1, 0); for (int i = N; i >= 1; i--) { int COUNT = 0; int C = 2; while (C * i < N) { COUNT += ANS[C * i]; C++; } ANS[i] = vec[i] ^ (COUNT % 2); } int M = 0; vector<int> index; for (int i = 1; i <= N; i++) { M += ANS[i]; if (ANS[i] > 0) index.push_back(i); } cout << M << endl; if (M == 0) return; for (int i = 0; i < index.size(); i++) { if (i != 0) cout << " "; cout << index[i]; } cout << endl; return; } int32_t main(int32_t argc, const char *argv[]) { std::ios::sync_with_stdio(false); std::cin.tie(0); std::cout << std::fixed; std::cout << std::setprecision(9); solve(); return 0; }
#include <algorithm> #include <array> #include <cmath> #include <complex> #include <cstdio> #include <deque> #include <float.h> #include <functional> #include <iomanip> #include <iostream> #include <limits.h> #include <list> #include <map> #include <numeric> #include <queue> #include <set> #include <sstream> #include <stack> #include <stdio.h> #include <string.h> #include <string> #include <tuple> #include <unordered_map> #include <vector> using namespace std; #define int long long #define I32_MAX 2147483647 #define I64_MAX 9223372036854775807LL #define I64_MAX2 1223372036854775807LL #define INF I64_MAX2 #define MOD 1000000007 #define MEM_SIZE 10000 #define DEBUG_OUT true #define ALL(x) (x).begin(), (x).end() // int DP[MEM_SIZE][MEM_SIZE] = {0}; // int GMEM[MEM_SIZE][MEM_SIZE] = {0}; template <typename T> void DEBUG(T e) { if (DEBUG_OUT == false) return; std::cout << e << std::endl; } template <typename T> void DEBUG(const std::vector<T> &v) { if (DEBUG_OUT == false) return; for (const auto &e : v) { std::cout << e << " "; } std::cout << std::endl; } template <typename T> void DEBUG(const std::vector<std::vector<T>> &vv) { if (DEBUG_OUT == false) return; for (const auto &v : vv) { DEBUG(v); } } template <class T, class X> void DEBUG(X d, T e) { if (DEBUG_OUT == false) return; std::cout << d << " "; DEBUG(e); }; template <class T> void corner(bool flg, T hoge) { if (flg) { cout << hoge << endl; exit(0); } } template <typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); } template <typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); } template <typename T> using matrix = vector<vector<T>>; vector<int> divisor(int n) { vector<int> ret; for (int i = 1; i * i <= n; i++) { if (n % i == 0) { ret.push_back(i); if (i * i != n) ret.push_back(n / i); } } sort(begin(ret), end(ret)); return (ret); } // FUNCTION void solve(void) { int N; cin >> N; vector<int> vec(N + 1); for (int i = 0; i < N; i++) { cin >> vec[i + 1]; } vector<int> ANS(N + 1, 0); for (int i = N; i >= 1; i--) { int COUNT = 0; int C = 2; while (C * i <= N) { COUNT += ANS[C * i]; C++; } ANS[i] = vec[i] ^ (COUNT % 2); } int M = 0; vector<int> index; for (int i = 1; i <= N; i++) { M += ANS[i]; if (ANS[i] > 0) index.push_back(i); } cout << M << endl; if (M == 0) return; for (int i = 0; i < index.size(); i++) { if (i != 0) cout << " "; cout << index[i]; } cout << endl; return; } int32_t main(int32_t argc, const char *argv[]) { std::ios::sync_with_stdio(false); std::cin.tie(0); std::cout << std::fixed; std::cout << std::setprecision(9); solve(); return 0; }
[ "expression.operator.compare.change", "control_flow.loop.condition.change" ]
777,940
777,941
u221285045
cpp
p02972
#include <algorithm> #include <array> #include <cmath> #include <complex> #include <cstdio> #include <deque> #include <float.h> #include <functional> #include <iomanip> #include <iostream> #include <limits.h> #include <list> #include <map> #include <numeric> #include <queue> #include <set> #include <sstream> #include <stack> #include <stdio.h> #include <string.h> #include <string> #include <tuple> #include <unordered_map> #include <vector> using namespace std; #define int long long #define I32_MAX 2147483647 #define I64_MAX 9223372036854775807LL #define I64_MAX2 1223372036854775807LL #define INF I64_MAX2 #define MOD 1000000007 #define MEM_SIZE 10000 #define DEBUG_OUT true #define ALL(x) (x).begin(), (x).end() // int DP[MEM_SIZE][MEM_SIZE] = {0}; // int GMEM[MEM_SIZE][MEM_SIZE] = {0}; template <typename T> void DEBUG(T e) { if (DEBUG_OUT == false) return; std::cout << e << std::endl; } template <typename T> void DEBUG(const std::vector<T> &v) { if (DEBUG_OUT == false) return; for (const auto &e : v) { std::cout << e << " "; } std::cout << std::endl; } template <typename T> void DEBUG(const std::vector<std::vector<T>> &vv) { if (DEBUG_OUT == false) return; for (const auto &v : vv) { DEBUG(v); } } template <class T, class X> void DEBUG(X d, T e) { if (DEBUG_OUT == false) return; std::cout << d << " "; DEBUG(e); }; template <class T> void corner(bool flg, T hoge) { if (flg) { cout << hoge << endl; exit(0); } } template <typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); } template <typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); } template <typename T> using matrix = vector<vector<T>>; vector<int> divisor(int n) { vector<int> ret; for (int i = 1; i * i <= n; i++) { if (n % i == 0) { ret.push_back(i); if (i * i != n) ret.push_back(n / i); } } sort(begin(ret), end(ret)); return (ret); } // FUNCTION void solve(void) { int N; cin >> N; vector<int> vec(N + 1); for (int i = 0; i < N; i++) { cin >> vec[i + 1]; } vector<int> ANS(N, 0); for (int i = N; i >= 1; i--) { int COUNT = 0; int C = 2; while (C * i < N) { COUNT += ANS[C * i]; C++; } ANS[i] = vec[i] ^ (COUNT % 2); } int M = 0; vector<int> index; for (int i = 1; i <= N; i++) { M += ANS[i]; if (ANS[i] > 0) index.push_back(i); } cout << M << endl; if (M == 0) return; for (int i = 0; i < index.size(); i++) { if (i != 0) cout << " "; cout << index[i]; } cout << endl; return; } int32_t main(int32_t argc, const char *argv[]) { std::ios::sync_with_stdio(false); std::cin.tie(0); std::cout << std::fixed; std::cout << std::setprecision(9); solve(); return 0; }
#include <algorithm> #include <array> #include <cmath> #include <complex> #include <cstdio> #include <deque> #include <float.h> #include <functional> #include <iomanip> #include <iostream> #include <limits.h> #include <list> #include <map> #include <numeric> #include <queue> #include <set> #include <sstream> #include <stack> #include <stdio.h> #include <string.h> #include <string> #include <tuple> #include <unordered_map> #include <vector> using namespace std; #define int long long #define I32_MAX 2147483647 #define I64_MAX 9223372036854775807LL #define I64_MAX2 1223372036854775807LL #define INF I64_MAX2 #define MOD 1000000007 #define MEM_SIZE 10000 #define DEBUG_OUT true #define ALL(x) (x).begin(), (x).end() // int DP[MEM_SIZE][MEM_SIZE] = {0}; // int GMEM[MEM_SIZE][MEM_SIZE] = {0}; template <typename T> void DEBUG(T e) { if (DEBUG_OUT == false) return; std::cout << e << std::endl; } template <typename T> void DEBUG(const std::vector<T> &v) { if (DEBUG_OUT == false) return; for (const auto &e : v) { std::cout << e << " "; } std::cout << std::endl; } template <typename T> void DEBUG(const std::vector<std::vector<T>> &vv) { if (DEBUG_OUT == false) return; for (const auto &v : vv) { DEBUG(v); } } template <class T, class X> void DEBUG(X d, T e) { if (DEBUG_OUT == false) return; std::cout << d << " "; DEBUG(e); }; template <class T> void corner(bool flg, T hoge) { if (flg) { cout << hoge << endl; exit(0); } } template <typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); } template <typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); } template <typename T> using matrix = vector<vector<T>>; vector<int> divisor(int n) { vector<int> ret; for (int i = 1; i * i <= n; i++) { if (n % i == 0) { ret.push_back(i); if (i * i != n) ret.push_back(n / i); } } sort(begin(ret), end(ret)); return (ret); } // FUNCTION void solve(void) { int N; cin >> N; vector<int> vec(N + 1); for (int i = 0; i < N; i++) { cin >> vec[i + 1]; } vector<int> ANS(N + 1, 0); for (int i = N; i >= 1; i--) { int COUNT = 0; int C = 2; while (C * i <= N) { COUNT += ANS[C * i]; C++; } ANS[i] = vec[i] ^ (COUNT % 2); } int M = 0; vector<int> index; for (int i = 1; i <= N; i++) { M += ANS[i]; if (ANS[i] > 0) index.push_back(i); } cout << M << endl; if (M == 0) return; for (int i = 0; i < index.size(); i++) { if (i != 0) cout << " "; cout << index[i]; } cout << endl; return; } int32_t main(int32_t argc, const char *argv[]) { std::ios::sync_with_stdio(false); std::cin.tie(0); std::cout << std::fixed; std::cout << std::setprecision(9); solve(); return 0; }
[ "expression.operator.compare.change", "control_flow.loop.condition.change" ]
777,942
777,941
u221285045
cpp
p02972
#include <algorithm> #include <cmath> #include <cstdio> #include <deque> #include <functional> #include <iomanip> #include <iostream> #include <limits.h> #include <list> #include <map> #include <numeric> #include <queue> #include <set> #include <sstream> #include <stack> #include <string> #include <tuple> #include <unordered_map> #include <vector> using namespace std; #define i64 long long #define int long long #define I32_MAX 2147483647 #define I64_MAX 9223372036854775807 #define MOD 1000000007 void solve() { int N; cin >> N; vector<int> vec(N + 1, 0); vector<int> outvec(N + 1, 0); for (int i = 0; i < N; i++) { cin >> vec[i + 1]; } for (int i = N; i >= 1; i--) { int L = 2; int counting = 0; while (N - L * i >= 0) { if (vec[L * i] == 1) counting++; L++; } if (counting % 2 == vec[i]) { vec[i] = 0; } else { vec[i] = 1; } } int num = 0; for (int i = 1; i < N + 1; i++) { if (vec[i] == 1) num++; } cout << num << endl; for (int i = 1; i < N + 1; i++) { if (vec[i] == 1) cout << vec[i] << endl; } return; } int32_t main(int32_t argc, const char *argv[]) { // std::ios::sync_with_stdio(false); // std::cin.tie(0); // std::cout << std::fixed; // std::cout << std::setprecision(8); solve(); return 0; }
#include <algorithm> #include <cmath> #include <cstdio> #include <deque> #include <functional> #include <iomanip> #include <iostream> #include <limits.h> #include <list> #include <map> #include <numeric> #include <queue> #include <set> #include <sstream> #include <stack> #include <string> #include <tuple> #include <unordered_map> #include <vector> using namespace std; #define i64 long long #define int long long #define I32_MAX 2147483647 #define I64_MAX 9223372036854775807 #define MOD 1000000007 void solve() { int N; cin >> N; vector<int> vec(N + 1, 0); vector<int> outvec(N + 1, 0); for (int i = 0; i < N; i++) { cin >> vec[i + 1]; } for (int i = N; i >= 1; i--) { int L = 2; int counting = 0; while (N - L * i >= 0) { if (vec[L * i] == 1) counting++; L++; } if (counting % 2 == vec[i]) { vec[i] = 0; } else { vec[i] = 1; } } int num = 0; for (int i = 1; i < N + 1; i++) { if (vec[i] == 1) num++; } cout << num << endl; for (int i = 1; i < N + 1; i++) { if (vec[i] == 1) cout << i << endl; } return; } int32_t main(int32_t argc, const char *argv[]) { // std::ios::sync_with_stdio(false); // std::cin.tie(0); // std::cout << std::fixed; // std::cout << std::setprecision(8); solve(); return 0; }
[]
777,943
777,944
u221285045
cpp
p02972
#include <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < (n); ++i) #define all(v) (v).begin(), (v).end() #define rall(v) (v).rbegin(), (v).rend() #define strall(v) (v).cbegin(), (v).cend() using namespace std; using ll = long long; using P = pair<int, int>; using Graph = vector<vector<int>>; template <class t, class u> void chmax(t &a, u b) { if (a < b) a = b; } template <class t, class u> void chmin(t &a, u b) { if (b < a) a = b; } int main() { int n; cin >> n; vector<int> a(n + 1); rep(i, n) cin >> a[i + 1]; vector<int> b(n + 1); for (int i = n; i >= 1; --i) { int sum = 0; for (int j = i + 1; j <= n; j += i) { sum ^= b[j]; // xor } b[i] = sum ^ a[i]; // xor } vector<int> ans; for (int i = 1; i <= n; i++) { if (b[i]) ans.push_back(i); } cout << ans.size() << endl; rep(i, ans.size()) { printf("%d%c", ans[i], i + 1 == ans.size() ? '\n' : ' '); } return 0; }
#include <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < (n); ++i) #define all(v) (v).begin(), (v).end() #define rall(v) (v).rbegin(), (v).rend() #define strall(v) (v).cbegin(), (v).cend() using namespace std; using ll = long long; using P = pair<int, int>; using Graph = vector<vector<int>>; template <class t, class u> void chmax(t &a, u b) { if (a < b) a = b; } template <class t, class u> void chmin(t &a, u b) { if (b < a) a = b; } int main() { int n; cin >> n; vector<int> a(n + 1); rep(i, n) cin >> a[i + 1]; vector<int> b(n + 1); for (int i = n; i >= 1; --i) { int sum = 0; for (int j = i + i; j <= n; j += i) { sum ^= b[j]; // xor } b[i] = sum ^ a[i]; // xor } vector<int> ans; for (int i = 1; i <= n; i++) { if (b[i]) ans.push_back(i); } cout << ans.size() << endl; rep(i, ans.size()) { printf("%d%c", ans[i], i + 1 == ans.size() ? '\n' : ' '); } return 0; }
[ "identifier.replace.add", "literal.replace.remove", "control_flow.loop.for.initializer.change", "expression.operation.binary.change" ]
777,963
777,964
u106635407
cpp
p02972
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound #include <bitset> // bitset #include <cctype> // isupper, islower, isdigit, toupper, tolower #include <cstdint> // int64_t, int*_t #include <cstdio> // printf #include <deque> // deque #include <functional> #include <iomanip> #include <iostream> // cout, endl, cin #include <map> // map #include <math.h> #include <queue> // queue, priority_queue #include <set> // set #include <stack> // stack #include <string> // string, to_string, stoi #include <tuple> // tuple, make_tuple #include <unordered_map> // unordered_map #include <unordered_set> // unordered_set #include <utility> // pair, make_pair #include <vector> // vector using namespace std; #define ll long long using vt = ll; //ここで数値の型を変えられる #define rep(i, n) for (vt i = 0; i < (vt)(n); i++) #define reps(i, s, n) for (vt i = (vt)(s); i < (vt)(n); i++) #define all(v) v.begin(), v.end() #define P pair<int, int> const ll MOD = 1000000007; int main() { ll n, m = 0; cin >> n; vector<ll> a(n), b(n + 1, 0); rep(i, n) cin >> a.at(i); for (ll i = n - 1; i >= 0; i--) { ll s = 0, k = 1; while ((i + 1) * k < n) { s += b.at((i + 1) * k); k++; } if (s % 2 != a.at(i)) { b.at(i + 1)++; m++; } } cout << m << endl; rep(i, n + 1) { if (b.at(i) == 1) { cout << i << " "; } } return 0; }
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound #include <bitset> // bitset #include <cctype> // isupper, islower, isdigit, toupper, tolower #include <cstdint> // int64_t, int*_t #include <cstdio> // printf #include <deque> // deque #include <functional> #include <iomanip> #include <iostream> // cout, endl, cin #include <map> // map #include <math.h> #include <queue> // queue, priority_queue #include <set> // set #include <stack> // stack #include <string> // string, to_string, stoi #include <tuple> // tuple, make_tuple #include <unordered_map> // unordered_map #include <unordered_set> // unordered_set #include <utility> // pair, make_pair #include <vector> // vector using namespace std; #define ll long long using vt = ll; //ここで数値の型を変えられる #define rep(i, n) for (vt i = 0; i < (vt)(n); i++) #define reps(i, s, n) for (vt i = (vt)(s); i < (vt)(n); i++) #define all(v) v.begin(), v.end() #define P pair<int, int> const ll MOD = 1000000007; int main() { ll n, m = 0; cin >> n; vector<ll> a(n), b(n + 1, 0); rep(i, n) cin >> a.at(i); for (ll i = n - 1; i >= 0; i--) { ll s = 0, k = 1; while ((i + 1) * k <= n) { s += b.at((i + 1) * k); k++; } if (s % 2 != a.at(i)) { b.at(i + 1)++; m++; } } cout << m << endl; rep(i, n + 1) { if (b.at(i) == 1) { cout << i << " "; } } return 0; }
[ "expression.operator.compare.change", "control_flow.loop.condition.change" ]
777,967
777,968
u822725754
cpp
p02972
#include <bits/stdc++.h> #define FOR(i, a, b) for (int i = (a); i < (b); ++i) #define FORR(i, b, a) for (int i = (b)-1; i >= 0; --i) #define REP(i, n) for (int i = 0; i < (n); ++i) #define REPR(i, n) for (int i = (n)-1; i >= 0; --i) #define ITER(itr, v) for (auto itr = v.begin(); itr != v.end(); ++itr) #define SORT(v) sort(v.begin(), v.end()) #define REV(v) reverse(v.begin(), v.end()) #define sz(v) int(v.size()) using namespace std; typedef long long ll; typedef pair<int, int> P; int main() { cin.tie(0); ios::sync_with_stdio(false); int N; cin >> N; vector<int> a(N + 1); REP(i, N) { cin >> a[i + 1]; } vector<int> res; for (int i = N / 2; i > 0; --i) { int mod = 0; for (int j = i; j <= N; j += i) { mod = (mod + a[j]) % 2; } if (a[i] != mod) a[i] = !a[i]; if (a[i]) res.push_back(i); } cout << sz(res) << endl; for (auto &i : res) cout << i << " "; return 0; }
#include <bits/stdc++.h> #define FOR(i, a, b) for (int i = (a); i < (b); ++i) #define FORR(i, b, a) for (int i = (b)-1; i >= 0; --i) #define REP(i, n) for (int i = 0; i < (n); ++i) #define REPR(i, n) for (int i = (n)-1; i >= 0; --i) #define ITER(itr, v) for (auto itr = v.begin(); itr != v.end(); ++itr) #define SORT(v) sort(v.begin(), v.end()) #define REV(v) reverse(v.begin(), v.end()) #define SIZE(v) int(v.size()) using namespace std; typedef long long ll; typedef pair<int, int> P; int main() { cin.tie(0); ios::sync_with_stdio(false); int N; cin >> N; vector<int> a(N + 1); REP(i, N) { cin >> a[i + 1]; } vector<int> res; for (int i = N; i > 0; --i) { int mod = 0; for (int j = i; j <= N; j += i) { mod = (mod + a[j]) % 2; } if (a[i] != mod) a[i] = !a[i]; if (a[i]) res.push_back(i); } cout << SIZE(res) << endl; for (auto &i : res) cout << i << " "; return 0; }
[ "identifier.change", "control_flow.loop.for.initializer.change", "expression.operation.binary.remove", "call.function.change", "io.output.change" ]
777,969
777,970
u285991898
cpp
p02972
#include "bits/stdc++.h" #define DEBUG(x) cout << #x << ": " << x << endl; #define DEBUG_VEC(v) \ cout << #v << ":"; \ for (int i = 0; i < v.size(); i++) \ cout << " " << v[i]; \ cout << endl #define vi vector<int> #define vl vector<ll> #define vii vector<vector<int>> #define vll vector<vector<ll>> #define vs vector<string> #define pii pair<int, int> #define pis pair<int, string> #define psi pair<string, int> #define pll pair<ll, ll> #define rep(i, begin, end) \ for (__typeof(end) i = (begin) - ((begin) > (end)); \ i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end))) #define MOD 1000000007 #define mod 1000000009 #define pi 3.14159265358979323846 #define Sp(p) cout << setprecision(15) << fixed << p << endl; int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1}; int dx2[8] = {1, 1, 0, -1, -1, -1, 0, 1}, dy2[8] = {0, 1, 1, 1, 0, -1, -1, -1}; typedef long long ll; const int inf = 1000000001; const ll INF = 1e18 * 4; using namespace std; vi decompose(int i) { vi ans; for (int j = 1; j < (int)sqrt(i) + 1; j++) { if (i % j == 0) { ans.push_back(j); if (i / j != i) ans.push_back(i / j); } } return ans; } int main() { int N; cin >> N; vi a; vi b(N + 1, 0); vi box(N + 1, 0); rep(i, 0, N) { int x; cin >> x; a.push_back(x); } for (int i = N; i > 0; i--) { if ((a[i - 1] == 1 && b[i] % 2 == 0) || (a[i - 1] == 0 && b[i] % 2 == 1)) { b[i] += 1; box[i] += 1; vi yakusu = decompose(i); for (auto &j : yakusu) { if (j == i) continue; b[j] += 1; } } } ll cnt = accumulate(box.begin(), box.end(), 0LL); cout << cnt << endl; rep(i, 1, N + 1) { if (box[i]) cout << i << endl; } return 0; }
#include "bits/stdc++.h" #define DEBUG(x) cout << #x << ": " << x << endl; #define DEBUG_VEC(v) \ cout << #v << ":"; \ for (int i = 0; i < v.size(); i++) \ cout << " " << v[i]; \ cout << endl #define vi vector<int> #define vl vector<ll> #define vii vector<vector<int>> #define vll vector<vector<ll>> #define vs vector<string> #define pii pair<int, int> #define pis pair<int, string> #define psi pair<string, int> #define pll pair<ll, ll> #define rep(i, begin, end) \ for (__typeof(end) i = (begin) - ((begin) > (end)); \ i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end))) #define MOD 1000000007 #define mod 1000000009 #define pi 3.14159265358979323846 #define Sp(p) cout << setprecision(15) << fixed << p << endl; int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1}; int dx2[8] = {1, 1, 0, -1, -1, -1, 0, 1}, dy2[8] = {0, 1, 1, 1, 0, -1, -1, -1}; typedef long long ll; const int inf = 1000000001; const ll INF = 1e18 * 4; using namespace std; vi decompose(int i) { vi ans; for (int j = 1; j < (int)sqrt(i) + 1; j++) { if (i % j == 0) { ans.push_back(j); if ((int)(i / j) != j) ans.push_back(i / j); } } return ans; } int main() { int N; cin >> N; vi a; vi b(N + 1, 0); vi box(N + 1, 0); rep(i, 0, N) { int x; cin >> x; a.push_back(x); } for (int i = N; i > 0; i--) { if ((a[i - 1] == 1 && b[i] % 2 == 0) || (a[i - 1] == 0 && b[i] % 2 == 1)) { b[i] += 1; box[i] += 1; vi yakusu = decompose(i); for (auto &j : yakusu) { if (j == i) continue; b[j] += 1; } } } ll cnt = accumulate(box.begin(), box.end(), 0LL); cout << cnt << endl; rep(i, 1, N + 1) { if (box[i]) cout << i << endl; } return 0; }
[ "control_flow.branch.if.condition.change", "control_flow.loop.for.condition.change", "identifier.change" ]
777,973
777,974
u531436689
cpp
p02972
#include <bits/stdc++.h> using namespace std; typedef long long ll; int main() { long long n, ans = 0; cin >> n; long long a[n], b[n] = {}; for (int i = 0; i < n; i++) { cin >> a[i]; } for (int i = n; i >= 1; i--) { long long cnt = 0; for (int j = 2; j * i <= n; j++) { if (b[j * i - 1] == 1) { cnt++; } } if (cnt % 2 != a[i - 1]) { b[i - 1] = 1; ans++; } } cout << ans << endl; for (int i = 0; i < n; i++) { if (b[i] == 1) { cout << a[i] << " "; } } if (ans > 0) { cout << "\n"; } return 0; }
#include <bits/stdc++.h> using namespace std; typedef long long ll; int main() { long long n, ans = 0; cin >> n; long long a[n], b[n] = {}; for (int i = 0; i < n; i++) { cin >> a[i]; } for (int i = n; i >= 1; i--) { long long cnt = 0; for (int j = 2; j * i <= n; j++) { if (b[j * i - 1] == 1) { cnt++; } } if (cnt % 2 != a[i - 1]) { b[i - 1] = 1; ans++; } } cout << ans << endl; for (int i = 0; i < n; i++) { if (b[i] == 1) { cout << i + 1 << " "; } } if (ans > 0) { cout << "\n"; } return 0; }
[ "io.output.change" ]
777,975
777,976
u710232726
cpp
p02972
#include <iostream> #include <vector> using namespace std; vector<int> func(int n) { vector<int> fac, sub; for (int i = 2; i * i <= n; i++) { if (n % i == 0) { fac.push_back(i); if (n / i != i) sub.push_back(n / i); } } int l = sub.size(); for (int i = 0; i < l; i++) fac.push_back(sub[l - 1 - i]); return fac; } int main() { int n; cin >> n; vector<int> a(n + 1); for (int i = 0; i < n; i++) cin >> a[i + 1]; int *count = new int[n + 1]; for (int i = 0; i <= n; i++) count[i] = 0; vector<int> ans(n + 1, 0); int sum = 0; for (int i = n; i > 0; i--) { if (count[i] % 2 == 1 && a[i] == 1) { ans[i] = 0; } else if (count[i] % 2 == 1 && a[i] == 0) { ans[i] = 1; sum++; vector<int> fac = func(i); for (int j = 0; j < fac.size(); j++) count[fac[j]]++; } else if (count[i] % 2 == 0 && a[i] == 1) { ans[i] = 1; sum++; vector<int> fac = func(i); for (int j = 0; j < fac.size(); j++) count[fac[j]]++; } else { ans[i] = 0; } } cout << sum << endl; if (sum) { for (int i = 1; i <= n; i++) { if (ans[i] == 1) cout << i << " "; } cout << endl; } return 0; }
#include <iostream> #include <vector> using namespace std; vector<int> func(int n) { vector<int> fac, sub; for (int i = 1; i * i <= n; i++) { if (n % i == 0) { fac.push_back(i); if (n / i != i) sub.push_back(n / i); } } int l = sub.size(); for (int i = 0; i < l; i++) fac.push_back(sub[l - 1 - i]); return fac; } int main() { int n; cin >> n; vector<int> a(n + 1); for (int i = 0; i < n; i++) cin >> a[i + 1]; int *count = new int[n + 1]; for (int i = 0; i <= n; i++) count[i] = 0; vector<int> ans(n + 1, 0); int sum = 0; for (int i = n; i > 0; i--) { if (count[i] % 2 == 1 && a[i] == 1) { ans[i] = 0; } else if (count[i] % 2 == 1 && a[i] == 0) { ans[i] = 1; sum++; vector<int> fac = func(i); for (int j = 0; j < fac.size(); j++) count[fac[j]]++; } else if (count[i] % 2 == 0 && a[i] == 1) { ans[i] = 1; sum++; vector<int> fac = func(i); for (int j = 0; j < fac.size(); j++) count[fac[j]]++; } else { ans[i] = 0; } } cout << sum << endl; if (sum) { for (int i = 1; i <= n; i++) { if (ans[i] == 1) cout << i << " "; } cout << endl; } return 0; }
[ "literal.number.change", "variable_declaration.value.change", "control_flow.loop.for.initializer.change", "expression.off_by_one" ]
777,977
777,978
u110383054
cpp
p02972
#include <bits/stdc++.h> using namespace std; using i64 = int64_t; std::vector<i64> divisor(i64 n) { std::vector<i64> res; for (i64 i = 1; i * i <= n; i++) { if (n % i == 0) { res.push_back(i); if (i != n / i) res.push_back(n / i); } } return res; } int main() { int n; cin >> n; vector<int> v; for (int i = 0; i < n; ++i) { int a; cin >> a; v.push_back(a); } vector<int> rem(n + 1), ans(n + 1); int m = 0; for (int i = n; i > 0; --i) { auto d = divisor(i); if (rem[i] ^ v[i - 1]) { m++; ans[i] = 1; for (auto e : d) { rem[e] ^= 1; } } } cout << m << endl; if (m > 0) { vector<int> b; for (int i = 0; i < n; ++i) { if (ans[i + 1] > 0) b.push_back(ans[i + 1]); } for (int i = 0; i < m; ++i) { if (i) cout << " "; cout << b[i]; } cout << endl; } return 0; }
#include <bits/stdc++.h> using namespace std; using i64 = int64_t; std::vector<i64> divisor(i64 n) { std::vector<i64> res; for (i64 i = 1; i * i <= n; i++) { if (n % i == 0) { res.push_back(i); if (i != n / i) res.push_back(n / i); } } return res; } int main() { int n; cin >> n; vector<int> v; for (int i = 0; i < n; ++i) { int a; cin >> a; v.push_back(a); } vector<int> rem(n + 1), ans(n + 1); int m = 0; for (int i = n; i > 0; --i) { auto d = divisor(i); if (rem[i] ^ v[i - 1]) { m++; ans[i] = 1; for (auto e : d) { rem[e] ^= 1; } } } cout << m << endl; if (m > 0) { vector<int> b; for (int i = 0; i < n; ++i) { if (ans[i + 1] > 0) b.push_back(i + 1); } for (int i = 0; i < m; ++i) { if (i) cout << " "; cout << b[i]; } cout << endl; } return 0; }
[ "call.arguments.change" ]
777,979
777,980
u823112986
cpp
p02972
#include <bits/stdc++.h> #include <cmath> #include <math.h> using namespace std; using ll = long long; using vi = vector<int>; using vvi = vector<vi>; using vl = vector<ll>; using vvl = vector<vl>; using vs = vector<string>; using vvs = vector<vs>; using vc = vector<char>; using vvc = vector<vc>; using vb = vector<bool>; using vvb = vector<vb>; #define rep(i, n) \ ; \ for (int i = 0; i < n; i++) #define all(a) a.begin(), a.end() #define pb(a) push_back(a) #define pd(a) printf("%.10f\n", a) #define mem(a) memset(a, 0, sizeof(a)) #define f(i, a, b) for (int i = a; i < b; i++) #define pri(a) printf("%.14lf\n", a); #define MOD 1000000007 bool is_int_lround(double x) { return std::lround(x) == x; } ll keta(ll x) { ll n = 0; while (x > 0) { x /= 10; n++; } return n; } ll conbi(int n, int m) { cin >> n >> m; vector<ll> a(100); a[0] = 1; for (int i = 0; i < 14; i++) { a[i + 1] = a[i] * (i + 1); } return a[n] / (a[m] * a[n - m]); } long long modpow(long long a, long long n, long long mod) { long long res = 1; //繰り返し二乗法 while (n > 0) { if (n & 1) res = res * a % mod; a = a * a % mod; n >>= 1; } return res; } ll kaijo(ll x) { ll z = 1; while (x > 0) { z *= x; z %= MOD; x--; } return z; } ll yakusu_num(ll n) { vl yakusu(n + 1, 1); for (ll i = 2; i * i <= n; i++) { while (n % i == 0) { n /= i; yakusu[i]++; } } if (n != 1) yakusu[n]++; ll num = 1; for (ll i = 0; i <= n; i++) { num *= yakusu[i]; } return num; } int main() { int N; cin >> N; vi a(N + 1); f(i, 1, N + 1) cin >> a[i]; vi b(N + 1); f(i, N / 2 + 1, N + 1) b[i] = a[i]; for (int i = N / 2; i > 0; i--) { for (int j = 2; i * j <= N; j++) { b[i] += b[j]; } if (b[i] % 2 == a[i]) b[i] = 0; else if (b[i] % 2 != a[i]) b[i] = 1; } int m = 0; rep(i, N + 1) { if (b[i] == 1) m++; } cout << m << endl; rep(i, N + 1) { if (b[i] == 1) cout << i << " "; } cout << endl; }
#include <bits/stdc++.h> #include <cmath> #include <math.h> using namespace std; using ll = long long; using vi = vector<int>; using vvi = vector<vi>; using vl = vector<ll>; using vvl = vector<vl>; using vs = vector<string>; using vvs = vector<vs>; using vc = vector<char>; using vvc = vector<vc>; using vb = vector<bool>; using vvb = vector<vb>; #define rep(i, n) \ ; \ for (int i = 0; i < n; i++) #define all(a) a.begin(), a.end() #define pb(a) push_back(a) #define pd(a) printf("%.10f\n", a) #define mem(a) memset(a, 0, sizeof(a)) #define f(i, a, b) for (int i = a; i < b; i++) #define pri(a) printf("%.14lf\n", a); #define MOD 1000000007 bool is_int_lround(double x) { return std::lround(x) == x; } ll keta(ll x) { ll n = 0; while (x > 0) { x /= 10; n++; } return n; } ll conbi(int n, int m) { cin >> n >> m; vector<ll> a(100); a[0] = 1; for (int i = 0; i < 14; i++) { a[i + 1] = a[i] * (i + 1); } return a[n] / (a[m] * a[n - m]); } long long modpow(long long a, long long n, long long mod) { long long res = 1; //繰り返し二乗法 while (n > 0) { if (n & 1) res = res * a % mod; a = a * a % mod; n >>= 1; } return res; } ll kaijo(ll x) { ll z = 1; while (x > 0) { z *= x; z %= MOD; x--; } return z; } ll yakusu_num(ll n) { vl yakusu(n + 1, 1); for (ll i = 2; i * i <= n; i++) { while (n % i == 0) { n /= i; yakusu[i]++; } } if (n != 1) yakusu[n]++; ll num = 1; for (ll i = 0; i <= n; i++) { num *= yakusu[i]; } return num; } int main() { int N; cin >> N; vi a(N + 1); f(i, 1, N + 1) cin >> a[i]; vi b(N + 1); f(i, N / 2 + 1, N + 1) b[i] = a[i]; for (int i = N / 2; i > 0; i--) { for (int j = 2; i * j <= N; j++) { b[i] += b[j * i]; } if (b[i] % 2 == a[i]) b[i] = 0; else if (b[i] % 2 != a[i]) b[i] = 1; } int m = 0; rep(i, N + 1) { if (b[i] == 1) m++; } cout << m << endl; rep(i, N + 1) { if (b[i] == 1) cout << i << " "; } cout << endl; }
[ "assignment.change" ]
777,981
777,982
u776056110
cpp
p02972
#include <bits/stdc++.h> using namespace std; int main() { int N; cin >> N; vector<int> a(N); for (int i = 0; i < N; i++) cin >> a.at(i); vector<int> sample(N); for (int i = N / 2; i < N; i++) sample.at(i) = a.at(i); int sum; for (int i = N / 2 - 1; i >= 0; i--) { sum = 0; for (int j = N / (i + 1); j > 1; j--) { sum += sample.at((i + 1) * j - 1); sum %= 2; if (a.at(i) != sum) sample.at(i) = 1; } } if (accumulate(sample.begin(), sample.end(), 0) != 0) { cout << accumulate(sample.begin(), sample.end(), 0) << endl; for (int i = 0; i < N; i++) if (sample.at(i) == 1) cout << i + 1 << " "; } else cout << 0; cout << endl; }
#include <bits/stdc++.h> using namespace std; int main() { int N; cin >> N; vector<int> a(N); for (int i = 0; i < N; i++) cin >> a.at(i); vector<int> sample(N); for (int i = N / 2; i < N; i++) sample.at(i) = a.at(i); int sum; for (int i = N / 2 - 1; i >= 0; i--) { sum = 0; for (int j = N / (i + 1); j > 1; j--) { sum += sample.at((i + 1) * j - 1); sum %= 2; } if (a.at(i) != sum) sample.at(i) = 1; } if (accumulate(sample.begin(), sample.end(), 0) != 0) { cout << accumulate(sample.begin(), sample.end(), 0) << endl; for (int i = 0; i < N; i++) if (sample.at(i) == 1) cout << i + 1 << " "; } else cout << 0; cout << endl; }
[]
777,991
777,992
u936602931
cpp
p02972
#include <bits/stdc++.h> using namespace std; int main() { int N; cin >> N; vector<int> a(N); for (int i = 0; i < N; i++) cin >> a.at(i); vector<int> sample(N); for (int i = N / 2; i < N - 1; i++) sample.at(i) = a.at(i); int sum; for (int i = N / 2 - 1; i >= 0; i--) { sum = 0; for (int j = N / (i + 1); j > 1; j--) { sum += sample.at((i + 1) * j - 1); sum %= 2; if (a.at(i) != sum) sample.at(i) = 1; } } if (accumulate(sample.begin(), sample.end(), 0) != 0) { cout << accumulate(sample.begin(), sample.end(), 0) << endl; for (int i = 0; i < N; i++) if (sample.at(i) == 1) cout << i + 1 << " "; } else cout << 0; cout << endl; }
#include <bits/stdc++.h> using namespace std; int main() { int N; cin >> N; vector<int> a(N); for (int i = 0; i < N; i++) cin >> a.at(i); vector<int> sample(N); for (int i = N / 2; i < N; i++) sample.at(i) = a.at(i); int sum; for (int i = N / 2 - 1; i >= 0; i--) { sum = 0; for (int j = N / (i + 1); j > 1; j--) { sum += sample.at((i + 1) * j - 1); sum %= 2; } if (a.at(i) != sum) sample.at(i) = 1; } if (accumulate(sample.begin(), sample.end(), 0) != 0) { cout << accumulate(sample.begin(), sample.end(), 0) << endl; for (int i = 0; i < N; i++) if (sample.at(i) == 1) cout << i + 1 << " "; } else cout << 0; cout << endl; }
[ "control_flow.loop.for.condition.change", "expression.operation.binary.remove" ]
777,993
777,992
u936602931
cpp
p02972
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; vector<int> a(n); for (int i = 0; i < n; i++) { cin >> a[i]; } int count = 0; for (int i = n - 1; i >= 0; i--) { for (int j = i * 2 + 1; j < n; j += i + 1) { a[i] ^= a[j]; } count += a[i]; } cout << count << endl; for (int i = 0; i < n; i++) { if (a[i]) cout << i + " "; } }
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; vector<int> a(n); for (int i = 0; i < n; i++) { cin >> a[i]; } int count = 0; for (int i = n - 1; i >= 0; i--) { for (int j = i * 2 + 1; j < n; j += i + 1) { a[i] ^= a[j]; } count += a[i]; } cout << count << endl; for (int i = 0; i < n; i++) { if (a[i]) cout << i + 1 << " "; } }
[ "io.output.change" ]
777,994
777,995
u154898295
cpp
p02972
#include <algorithm> #include <cstdio> #include <iostream> #include <string> #include <utility> #include <vector> using namespace std; int main() { int n; cin >> n; vector<int> a(n + 1, 0); for (int i = 1; i <= n; i++) { cin >> a[i]; } vector<int> ball(n + 1, 0); vector<int> ans; for (int i = n; i >= 1; i--) { if (ball[i] % 2 == a[i]) { continue; } ans.emplace_back(i); for (int j = 1; j * j <= i; j++) { if (i % j == 0) { ball[j]++; if (i * j != n) { ball[i / j]++; } } } } cout << ans.size() << endl; for (int i = 0; i < ans.size(); i++) { if (i != 0) { cout << " "; } cout << ans[i]; } cout << endl; return 0; }
#include <algorithm> #include <cstdio> #include <iostream> #include <string> #include <utility> #include <vector> using namespace std; int main() { int n; cin >> n; vector<int> a(n + 1, 0); for (int i = 1; i <= n; i++) { cin >> a[i]; } vector<int> ball(n + 1, 0); vector<int> ans; for (int i = n; i >= 1; i--) { if (ball[i] % 2 == a[i]) { continue; } ans.emplace_back(i); for (int j = 1; j * j <= i; j++) { if (i % j == 0) { ball[j]++; if (j * j != i) { ball[i / j]++; } } } } cout << ans.size() << endl; for (int i = 0; i < ans.size(); i++) { if (i != 0) { cout << " "; } cout << ans[i]; } cout << endl; return 0; }
[ "identifier.change", "control_flow.branch.if.condition.change" ]
777,996
777,997
u590241855
cpp
p02972
#include <algorithm> #include <cstdio> #include <iostream> #include <string> #include <utility> #include <vector> using namespace std; int main() { int n; cin >> n; vector<int> a(n + 1, 0); for (int i = 1; i <= n; i++) { cin >> a[i]; } vector<int> ball(n + 1, 0); vector<int> ans; for (int i = n; i >= 1; i--) { if (ball[i] % 2 == a[i]) { continue; } ans.emplace_back(i); for (int j = 1; j * j <= n; j++) { if (i % j == 0) { ball[j]++; if (i * j != n) { ball[i / j]++; } } } } cout << ans.size() << endl; for (int i = 0; i < ans.size(); i++) { if (i != 0) { cout << " "; } cout << ans[i]; } cout << endl; return 0; }
#include <algorithm> #include <cstdio> #include <iostream> #include <string> #include <utility> #include <vector> using namespace std; int main() { int n; cin >> n; vector<int> a(n + 1, 0); for (int i = 1; i <= n; i++) { cin >> a[i]; } vector<int> ball(n + 1, 0); vector<int> ans; for (int i = n; i >= 1; i--) { if (ball[i] % 2 == a[i]) { continue; } ans.emplace_back(i); for (int j = 1; j * j <= i; j++) { if (i % j == 0) { ball[j]++; if (j * j != i) { ball[i / j]++; } } } } cout << ans.size() << endl; for (int i = 0; i < ans.size(); i++) { if (i != 0) { cout << " "; } cout << ans[i]; } cout << endl; return 0; }
[ "identifier.change", "control_flow.loop.for.condition.change", "expression.operation.binary.change", "control_flow.branch.if.condition.change" ]
777,998
777,997
u590241855
cpp
p02972
// >>> TEMPLATES #include <bits/stdc++.h> using namespace std; using ll = long long; using ld = long double; using i32 = int32_t; using i64 = int64_t; #define int ll #define double ld #define rep(i, n) for (int i = 0; i < (int)(n); i++) #define rep1(i, n) for (int i = 1; i <= (int)(n); i++) #define repR(i, n) for (int i = (int)(n)-1; i >= 0; i--) #define rep1R(i, n) for (int i = (int)(n); i >= 1; i--) #define loop(i, a, B) for (int i = a; i B; i++) #define loopR(i, a, B) for (int i = a; i B; i--) #define all(x) (x).begin(), (x).end() #define allR(x) (x).rbegin(), (x).rend() #define pb push_back #define eb emplace_back #define mp make_pair #define fst first #define snd second auto constexpr INF32 = numeric_limits<int32_t>::max() / 2 - 1; auto constexpr INF64 = numeric_limits<int64_t>::max() / 2 - 1; auto constexpr INF = numeric_limits<int>::max() / 2 - 1; #ifdef LOCAL #include "debug.hpp" #define dump(...) \ cerr << "[" << setw(3) << __LINE__ << ":" << __FUNCTION__ << "] ", \ dump_impl(#__VA_ARGS__, __VA_ARGS__) #define say(x) \ cerr << "[" << __LINE__ << ":" << __FUNCTION__ << "] " << x << endl #define debug if (1) #else #define dump(...) (void)(0) #define say(x) (void)(0) #define debug if (0) #endif template <class T> using pque_max = priority_queue<T>; template <class T> using pque_min = priority_queue<T, vector<T>, greater<T>>; template <class T, class = typename T::iterator, class = typename enable_if<!is_same<T, string>::value>::type> ostream &operator<<(ostream &os, T const &v) { bool f = true; for (auto const &x : v) os << (f ? "" : " ") << x, f = false; return os; } template <class T, class = typename T::iterator, class = typename enable_if<!is_same<T, string>::value>::type> istream &operator>>(istream &is, T &v) { for (auto &x : v) is >> x; return is; } template <class T, class S> istream &operator>>(istream &is, pair<T, S> &p) { return is >> p.first >> p.second; } struct IOSetup { IOSetup() { cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); } } iosetup; template <class F> struct FixPoint : private F { constexpr FixPoint(F &&f) : F(forward<F>(f)) {} template <class... T> constexpr auto operator()(T &&...x) const { return F::operator()(*this, forward<T>(x)...); } }; struct MakeFixPoint { template <class F> constexpr auto operator|(F &&f) const { return FixPoint<F>(forward<F>(f)); } }; #define MFP MakeFixPoint() | #define def(name, ...) auto name = MFP[&](auto &&name, __VA_ARGS__) template <class T, size_t d> struct vec_impl { using type = vector<typename vec_impl<T, d - 1>::type>; template <class... U> static type make_v(size_t n, U &&...x) { return type(n, vec_impl<T, d - 1>::make_v(forward<U>(x)...)); } }; template <class T> struct vec_impl<T, 0> { using type = T; static type make_v(T const &x = {}) { return x; } }; template <class T, size_t d = 1> using vec = typename vec_impl<T, d>::type; template <class T, size_t d = 1, class... Args> auto make_v(Args &&...args) { return vec_impl<T, d>::make_v(forward<Args>(args)...); } template <class T> void quit(T const &x) { cout << x << endl; exit(0); } template <class T> constexpr bool chmin(T &x, T const &y) { if (x > y) { x = y; return true; } return false; } template <class T> constexpr bool chmax(T &x, T const &y) { if (x < y) { x = y; return true; } return false; } template <class It> constexpr auto sumof(It b, It e) { return accumulate(b, e, typename iterator_traits<It>::value_type{}); } template <class T> int sz(T const &x) { return x.size(); } template <class C, class T> int lbd(C const &v, T const &x) { return lower_bound(v.begin(), v.end(), x) - v.begin(); } template <class C, class T> int ubd(C const &v, T const &x) { return upper_bound(v.begin(), v.end(), x) - v.begin(); } template <class C, class F> int ppt(C const &v, F f) { return partition_point(v.begin(), v.end(), f) - v.begin(); } // <<< int32_t main() { int n; cin >> n; vector<int> a(n); cin >> a; a.insert(a.begin(), 0); rep1R(i, n) { for (int j = 2 * i; j <= n; ++j) { a[i] ^= a[j]; } } dump(a); int m = count(all(a), 1); cout << m << endl; rep1(i, n) if (a[i]) cout << i << " "; cout << endl; }
// >>> TEMPLATES #include <bits/stdc++.h> using namespace std; using ll = long long; using ld = long double; using i32 = int32_t; using i64 = int64_t; #define int ll #define double ld #define rep(i, n) for (int i = 0; i < (int)(n); i++) #define rep1(i, n) for (int i = 1; i <= (int)(n); i++) #define repR(i, n) for (int i = (int)(n)-1; i >= 0; i--) #define rep1R(i, n) for (int i = (int)(n); i >= 1; i--) #define loop(i, a, B) for (int i = a; i B; i++) #define loopR(i, a, B) for (int i = a; i B; i--) #define all(x) (x).begin(), (x).end() #define allR(x) (x).rbegin(), (x).rend() #define pb push_back #define eb emplace_back #define mp make_pair #define fst first #define snd second auto constexpr INF32 = numeric_limits<int32_t>::max() / 2 - 1; auto constexpr INF64 = numeric_limits<int64_t>::max() / 2 - 1; auto constexpr INF = numeric_limits<int>::max() / 2 - 1; #ifdef LOCAL #include "debug.hpp" #define dump(...) \ cerr << "[" << setw(3) << __LINE__ << ":" << __FUNCTION__ << "] ", \ dump_impl(#__VA_ARGS__, __VA_ARGS__) #define say(x) \ cerr << "[" << __LINE__ << ":" << __FUNCTION__ << "] " << x << endl #define debug if (1) #else #define dump(...) (void)(0) #define say(x) (void)(0) #define debug if (0) #endif template <class T> using pque_max = priority_queue<T>; template <class T> using pque_min = priority_queue<T, vector<T>, greater<T>>; template <class T, class = typename T::iterator, class = typename enable_if<!is_same<T, string>::value>::type> ostream &operator<<(ostream &os, T const &v) { bool f = true; for (auto const &x : v) os << (f ? "" : " ") << x, f = false; return os; } template <class T, class = typename T::iterator, class = typename enable_if<!is_same<T, string>::value>::type> istream &operator>>(istream &is, T &v) { for (auto &x : v) is >> x; return is; } template <class T, class S> istream &operator>>(istream &is, pair<T, S> &p) { return is >> p.first >> p.second; } struct IOSetup { IOSetup() { cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); } } iosetup; template <class F> struct FixPoint : private F { constexpr FixPoint(F &&f) : F(forward<F>(f)) {} template <class... T> constexpr auto operator()(T &&...x) const { return F::operator()(*this, forward<T>(x)...); } }; struct MakeFixPoint { template <class F> constexpr auto operator|(F &&f) const { return FixPoint<F>(forward<F>(f)); } }; #define MFP MakeFixPoint() | #define def(name, ...) auto name = MFP[&](auto &&name, __VA_ARGS__) template <class T, size_t d> struct vec_impl { using type = vector<typename vec_impl<T, d - 1>::type>; template <class... U> static type make_v(size_t n, U &&...x) { return type(n, vec_impl<T, d - 1>::make_v(forward<U>(x)...)); } }; template <class T> struct vec_impl<T, 0> { using type = T; static type make_v(T const &x = {}) { return x; } }; template <class T, size_t d = 1> using vec = typename vec_impl<T, d>::type; template <class T, size_t d = 1, class... Args> auto make_v(Args &&...args) { return vec_impl<T, d>::make_v(forward<Args>(args)...); } template <class T> void quit(T const &x) { cout << x << endl; exit(0); } template <class T> constexpr bool chmin(T &x, T const &y) { if (x > y) { x = y; return true; } return false; } template <class T> constexpr bool chmax(T &x, T const &y) { if (x < y) { x = y; return true; } return false; } template <class It> constexpr auto sumof(It b, It e) { return accumulate(b, e, typename iterator_traits<It>::value_type{}); } template <class T> int sz(T const &x) { return x.size(); } template <class C, class T> int lbd(C const &v, T const &x) { return lower_bound(v.begin(), v.end(), x) - v.begin(); } template <class C, class T> int ubd(C const &v, T const &x) { return upper_bound(v.begin(), v.end(), x) - v.begin(); } template <class C, class F> int ppt(C const &v, F f) { return partition_point(v.begin(), v.end(), f) - v.begin(); } // <<< int32_t main() { int n; cin >> n; vector<int> a(n); cin >> a; a.insert(a.begin(), 0); rep1R(i, n) { for (int j = 2 * i; j <= n; j += i) { a[i] ^= a[j]; } } dump(a); int m = count(all(a), 1); cout << m << endl; rep1(i, n) if (a[i]) cout << i << " "; cout << endl; }
[ "control_flow.loop.for.update.change", "assignment.change" ]
778,011
778,012
u200215998
cpp
p02972
// >>> TEMPLATES #include <bits/stdc++.h> using namespace std; #define rep(i, n) for (int i = 0; i < int(n); i++) #define rep1(i, n) for (int i = 1; i <= int(n); i++) #define repR(i, n) for (int i = int(n) - 1; i >= 0; i--) #define rep1R(i, n) for (int i = int(n); i >= 1; i--) #define loop(i, a, B) for (int i = a; i B; i++) #define loopR(i, a, B) for (int i = a; i B; i--) #define all(x) (x).begin(), (x).end() #define allR(x) (x).rbegin(), (x).rend() #define pb push_back #define eb emplace_back #define mp make_pair #define fst first #define snd second #ifdef LOCAL #define dump(...) \ cerr << "[" << __LINE__ << ":" << __FUNCTION__ << "] ", \ dump_impl(#__VA_ARGS__, __VA_ARGS__) #define say(x) \ cerr << "[" << __LINE__ << ":" << __FUNCTION__ << "] " << x << endl; #define debug if (1) void dump_impl(const char *) { cerr << endl; } template <class T, class... U> void dump_impl(const char *s, T const &x, U const &...y) { const char *o = "({[", *e = "]})"; for (int i = 0; *s != '\0'; cerr << *s++) { if (count(o, o + 3, *s)) i++; if (count(e, e + 3, *s)) i--; if (!i && *s == ',') break; } cerr << " = " << x; if (*s == ',') cerr << ", ", s++; dump_impl(s, y...); } #else #define dump(...) #define say(x) #define debug if (0) #endif using ll = long long; using ld = long double; template <class T> using pque_max = priority_queue<T>; template <class T> using pque_min = priority_queue<T, vector<T>, greater<T>>; template <class T, class = typename T::iterator, class = typename enable_if<!is_same<T, string>::value>::type> ostream &operator<<(ostream &os, T const &v) { os << "{"; for (auto const &x : v) os << " " << x; return os << " }"; } template <class T> istream &operator>>(istream &is, vector<T> &v) { for (auto &x : v) is >> x; return is; } template <class T, class S> ostream &operator<<(ostream &os, pair<T, S> const &p) { return os << "(" << p.first << ", " << p.second << ")"; } template <class T, class S> istream &operator>>(istream &is, pair<T, S> &p) { return is >> p.first >> p.second; } template <size_t i, class T> typename enable_if<i >= tuple_size<T>::value>::type output_tuple(ostream &, T const &) {} template <size_t i = 0, class T> typename enable_if < i<tuple_size<T>::value>::type output_tuple(ostream &os, T const &t) { os << (i ? " " : "") << get<i>(t); output_tuple<i + 1, T>(os, t); } template <class... T> ostream &operator<<(ostream &os, tuple<T...> const &t) { return output_tuple(os, t), os; } struct IOSetup { IOSetup() { cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); } } iosetup; template <class F> struct FixPoint : private F { constexpr FixPoint(F &&f) : F(forward<F>(f)) {} template <class... T> constexpr auto operator()(T &&...x) const { return F::operator()(*this, forward<T>(x)...); } }; struct MakeFixPoint { template <class F> constexpr auto operator|(F &&f) const { return FixPoint<F>(forward<F>(f)); } }; #define MFP MakeFixPoint() | #define def(name, ...) auto name = MFP[&](auto &&name, __VA_ARGS__) template <class T, size_t d> struct vec_impl { using type = vector<typename vec_impl<T, d - 1>::type>; template <class... U> static type make_v(size_t n, U &&...x) { return type(n, vec_impl<T, d - 1>::make_v(forward<U>(x)...)); } }; template <class T> struct vec_impl<T, 0> { using type = T; static type make_v(T const &x = {}) { return x; } }; template <class T, size_t d = 1> using vec = typename vec_impl<T, d>::type; template <class T, size_t d = 1, class... Args> auto make_v(Args &&...args) { return vec_impl<T, d>::make_v(forward<Args>(args)...); } template <class T> void quit(T const &x) { cout << x << endl; exit(0); } template <class T> constexpr bool chmin(T &x, T const &y) { if (x > y) { x = y; return true; } return false; } template <class T> constexpr bool chmax(T &x, T const &y) { if (x < y) { x = y; return true; } return false; } template <class It> constexpr auto sumof(It b, It e) { return accumulate(b, e, typename iterator_traits<It>::value_type{}); } #define int ll #define double ld template <class T> int sz(T const &x) { return x.size(); } const ll INF = (1LL << 62) - 1; // ~ 4.6e18 // <<< int32_t main() { int n; cin >> n; vector<int> a(n + 1); rep1(i, n) cin >> a[i]; vector<int> x(n + 1); rep1R(i, n) { x[i] = a[i]; for (int j = 2 * i; j <= n; j += i) x[i] ^= a[j]; } vector<int> b; rep1(i, n) if (x[i]) b.eb(i); cout << sz(b) << endl; for (int y : b) cout << y << " "; cout << endl; }
// >>> TEMPLATES #include <bits/stdc++.h> using namespace std; #define rep(i, n) for (int i = 0; i < int(n); i++) #define rep1(i, n) for (int i = 1; i <= int(n); i++) #define repR(i, n) for (int i = int(n) - 1; i >= 0; i--) #define rep1R(i, n) for (int i = int(n); i >= 1; i--) #define loop(i, a, B) for (int i = a; i B; i++) #define loopR(i, a, B) for (int i = a; i B; i--) #define all(x) (x).begin(), (x).end() #define allR(x) (x).rbegin(), (x).rend() #define pb push_back #define eb emplace_back #define mp make_pair #define fst first #define snd second #ifdef LOCAL #define dump(...) \ cerr << "[" << __LINE__ << ":" << __FUNCTION__ << "] ", \ dump_impl(#__VA_ARGS__, __VA_ARGS__) #define say(x) \ cerr << "[" << __LINE__ << ":" << __FUNCTION__ << "] " << x << endl; #define debug if (1) void dump_impl(const char *) { cerr << endl; } template <class T, class... U> void dump_impl(const char *s, T const &x, U const &...y) { const char *o = "({[", *e = "]})"; for (int i = 0; *s != '\0'; cerr << *s++) { if (count(o, o + 3, *s)) i++; if (count(e, e + 3, *s)) i--; if (!i && *s == ',') break; } cerr << " = " << x; if (*s == ',') cerr << ", ", s++; dump_impl(s, y...); } #else #define dump(...) #define say(x) #define debug if (0) #endif using ll = long long; using ld = long double; template <class T> using pque_max = priority_queue<T>; template <class T> using pque_min = priority_queue<T, vector<T>, greater<T>>; template <class T, class = typename T::iterator, class = typename enable_if<!is_same<T, string>::value>::type> ostream &operator<<(ostream &os, T const &v) { os << "{"; for (auto const &x : v) os << " " << x; return os << " }"; } template <class T> istream &operator>>(istream &is, vector<T> &v) { for (auto &x : v) is >> x; return is; } template <class T, class S> ostream &operator<<(ostream &os, pair<T, S> const &p) { return os << "(" << p.first << ", " << p.second << ")"; } template <class T, class S> istream &operator>>(istream &is, pair<T, S> &p) { return is >> p.first >> p.second; } template <size_t i, class T> typename enable_if<i >= tuple_size<T>::value>::type output_tuple(ostream &, T const &) {} template <size_t i = 0, class T> typename enable_if < i<tuple_size<T>::value>::type output_tuple(ostream &os, T const &t) { os << (i ? " " : "") << get<i>(t); output_tuple<i + 1, T>(os, t); } template <class... T> ostream &operator<<(ostream &os, tuple<T...> const &t) { return output_tuple(os, t), os; } struct IOSetup { IOSetup() { cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); } } iosetup; template <class F> struct FixPoint : private F { constexpr FixPoint(F &&f) : F(forward<F>(f)) {} template <class... T> constexpr auto operator()(T &&...x) const { return F::operator()(*this, forward<T>(x)...); } }; struct MakeFixPoint { template <class F> constexpr auto operator|(F &&f) const { return FixPoint<F>(forward<F>(f)); } }; #define MFP MakeFixPoint() | #define def(name, ...) auto name = MFP[&](auto &&name, __VA_ARGS__) template <class T, size_t d> struct vec_impl { using type = vector<typename vec_impl<T, d - 1>::type>; template <class... U> static type make_v(size_t n, U &&...x) { return type(n, vec_impl<T, d - 1>::make_v(forward<U>(x)...)); } }; template <class T> struct vec_impl<T, 0> { using type = T; static type make_v(T const &x = {}) { return x; } }; template <class T, size_t d = 1> using vec = typename vec_impl<T, d>::type; template <class T, size_t d = 1, class... Args> auto make_v(Args &&...args) { return vec_impl<T, d>::make_v(forward<Args>(args)...); } template <class T> void quit(T const &x) { cout << x << endl; exit(0); } template <class T> constexpr bool chmin(T &x, T const &y) { if (x > y) { x = y; return true; } return false; } template <class T> constexpr bool chmax(T &x, T const &y) { if (x < y) { x = y; return true; } return false; } template <class It> constexpr auto sumof(It b, It e) { return accumulate(b, e, typename iterator_traits<It>::value_type{}); } #define int ll #define double ld template <class T> int sz(T const &x) { return x.size(); } const ll INF = (1LL << 62) - 1; // ~ 4.6e18 // <<< int32_t main() { int n; cin >> n; vector<int> a(n + 1); rep1(i, n) cin >> a[i]; vector<int> x(n + 1); rep1R(i, n) { x[i] = a[i]; for (int j = 2 * i; j <= n; j += i) x[i] ^= x[j]; } vector<int> b; rep1(i, n) if (x[i]) b.eb(i); cout << sz(b) << endl; for (int y : b) cout << y << " "; cout << endl; }
[ "assignment.value.change", "identifier.change" ]
778,013
778,014
u200215998
cpp
p02972
#include <bits/stdc++.h> #define rep(X, N) for (ll X = 0; X < (N); X++) #define PI (acos(-1.0)) #define pback push_back #define mpair make_pair #define MODN 1000000007 #define ALL(V) (V).begin(), (V).end() #define INT_MAX_HALF (INT_MAX / 2) #define EPS (1e-10) using namespace std; typedef long long ll; int main() { int n; cin >> n; vector<int> a(n + 1); vector<int> ans(n + 1); int count = 0; rep(i, n) { cin >> a[i + 1]; } for (int i = n; i >= 1; i--) { int tmp = 0; for (int j = i + i; j <= n; j = j + i) { tmp += a[j]; } if (a[i] == 0) { if (tmp % 2 == 0) { } else { ans[i] = 1; count++; } } else { if (tmp % 2 == 0) { ans[i] = 1; count++; } else { } } } cout << count << endl; rep(i, ans.size()) { if (ans[i + 1] == 1) cout << i + 1 << endl; } return 0; }
#include <bits/stdc++.h> #define rep(X, N) for (ll X = 0; X < (N); X++) #define PI (acos(-1.0)) #define pback push_back #define mpair make_pair #define MODN 1000000007 #define ALL(V) (V).begin(), (V).end() #define INT_MAX_HALF (INT_MAX / 2) #define EPS (1e-10) using namespace std; typedef long long ll; int main() { int n; cin >> n; vector<int> a(n + 1); vector<int> ans(n + 1); int count = 0; rep(i, n) { cin >> a[i + 1]; } for (int i = n; i >= 1; i--) { int tmp = 0; for (int j = i + i; j <= n; j = j + i) { tmp += ans[j]; } if (a[i] == 0) { if (tmp % 2 == 0) { } else { ans[i] = 1; count++; } } else { if (tmp % 2 == 0) { ans[i] = 1; count++; } else { } } } cout << count << endl; rep(i, ans.size()) { if (ans[i + 1] == 1) cout << i + 1 << endl; } return 0; }
[ "assignment.value.change", "identifier.change" ]
778,024
778,025
u145078501
cpp
p02972
#include <cstddef> #include <cstdint> #include <vector> namespace null_null { using i32 = std::int_fast32_t; using i64 = std::int_fast64_t; using u32 = std::uint_fast32_t; using u64 = std::uint_fast64_t; using usize = std::size_t; constexpr usize operator"" _z(unsigned long long x) noexcept { return static_cast<usize>(x); } template <typename T> std::vector<T> make_v(usize a) { return std::vector<T>(a); } template <typename T, typename... Ts> auto make_v(usize a, Ts... ts) { return std::vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...)); } template <typename T, typename V> typename std::enable_if<std::is_class<T>::value == 0>::type fill_v(T &t, const V &v) { t = v; } template <typename T, typename V> typename std ::enable_if<std::is_class<T>::value != 0>::type fill_v(T &t, const V &v) { for (auto &e : t) fill_v(e, v); } template <typename T, typename V> inline void chmin(T &a, V b) { if (a > b) a = b; } template <typename T, typename V> inline void chmax(T &a, V b) { if (a < b) a = b; } } // namespace null_null #include <algorithm> #include <iostream> #include <utility> namespace null_null { void main_() { usize N; std::cin >> N; std::vector<usize> a(N + 1, 0), ans(N + 1, 0), pla; for (usize i = 1; i <= N; i++) { std::cin >> a[i]; } for (usize i = N; i >= 1; i--) { usize sum = 0; for (usize j = 2; j * i <= N; j++) { sum += ans[j]; } if (sum % 2 != a[i]) { ans[i] = (ans[i] + 1) % 2; } } for (usize i = 1; i <= N; i++) { if (ans[i]) { pla.push_back(i); } } std::cout << pla.size() << std::endl; for (usize i = 0; i < pla.size(); i++) { std::cout << pla[i] << std::endl; } } } // namespace null_null int main() { null_null::main_(); return 0; }
#include <cstddef> #include <cstdint> #include <vector> namespace null_null { using i32 = std::int_fast32_t; using i64 = std::int_fast64_t; using u32 = std::uint_fast32_t; using u64 = std::uint_fast64_t; using usize = std::size_t; constexpr usize operator"" _z(unsigned long long x) noexcept { return static_cast<usize>(x); } template <typename T> std::vector<T> make_v(usize a) { return std::vector<T>(a); } template <typename T, typename... Ts> auto make_v(usize a, Ts... ts) { return std::vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...)); } template <typename T, typename V> typename std::enable_if<std::is_class<T>::value == 0>::type fill_v(T &t, const V &v) { t = v; } template <typename T, typename V> typename std ::enable_if<std::is_class<T>::value != 0>::type fill_v(T &t, const V &v) { for (auto &e : t) fill_v(e, v); } template <typename T, typename V> inline void chmin(T &a, V b) { if (a > b) a = b; } template <typename T, typename V> inline void chmax(T &a, V b) { if (a < b) a = b; } } // namespace null_null #include <algorithm> #include <iostream> #include <utility> namespace null_null { void main_() { usize N; std::cin >> N; std::vector<usize> a(N + 1, 0), ans(N + 1, 0), pla; for (usize i = 1; i <= N; i++) { std::cin >> a[i]; } for (usize i = N; i >= 1; i--) { usize sum = 0; for (usize j = 2; j * i <= N; j++) { sum += ans[j * i]; } if (sum % 2 != a[i]) { ans[i] = (ans[i] + 1) % 2; } } for (usize i = 1; i <= N; i++) { if (ans[i]) { pla.push_back(i); } } std::cout << pla.size() << std::endl; for (usize i = 0; i < pla.size(); i++) { std::cout << pla[i] << std::endl; } } } // namespace null_null int main() { null_null::main_(); return 0; }
[ "assignment.change" ]
778,026
778,027
u876978301
cpp
p02972
#include <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < n; i++) #define REPR(i, n) for (int i = n; i >= 0; i--) #define FOR(i, m, n) for (int i = m; i < n; i++) #define FORR(i, m, n) for (int i = m; i >= n; i--) #define pb(a) push_back(a) #define mk(a, b) make_pair(a, b) #define ll long long #define INF 999999999 #define IOS \ cin.tie(0); \ ios::sync_with_stdio(false) using namespace std; typedef pair<int, int> P; typedef pair<int, P> PP; typedef pair<ll, ll> LP; typedef pair<ll, LP> LPP; int dy[] = {0, 0, 1, -1}; int dx[] = {1, -1, 0, 0}; int gcd(int a, int b) { return b ? gcd(b, a % b) : a; } int lcm(int a, int b) { return a / gcd(a, b) * b; } int main() { int N; cin >> N; vector<int> T; vector<int> b; int count = 0; vector<int> A(200020); for (int i = 0; i < N; i++) { int a; cin >> a; T.push_back(a); } for (int i = N - 1; i >= 0; i--) { if (T[i] == A[i + 1] % 2) ; else { for (int j = 1; j * j <= i + 1; j++) { if ((i + 1) % j == 0) { A[j]++; if (j * j != i + 1) A[(i + 1) / j]++; } } b.push_back(T[i]); count++; } } reverse(b.begin(), b.end()); cout << count << endl; for (int i = 0; i < b.size(); i++) cout << b[i] << " " << flush; if (b.size() != 0) cout << endl; return 0; }
#include <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < n; i++) #define REPR(i, n) for (int i = n; i >= 0; i--) #define FOR(i, m, n) for (int i = m; i < n; i++) #define FORR(i, m, n) for (int i = m; i >= n; i--) #define pb(a) push_back(a) #define mk(a, b) make_pair(a, b) #define ll long long #define INF 999999999 #define IOS \ cin.tie(0); \ ios::sync_with_stdio(false) using namespace std; typedef pair<int, int> P; typedef pair<int, P> PP; typedef pair<ll, ll> LP; typedef pair<ll, LP> LPP; int dy[] = {0, 0, 1, -1}; int dx[] = {1, -1, 0, 0}; int gcd(int a, int b) { return b ? gcd(b, a % b) : a; } int lcm(int a, int b) { return a / gcd(a, b) * b; } int main() { int N; cin >> N; vector<int> T; vector<int> b; int count = 0; vector<int> A(200020); for (int i = 0; i < N; i++) { int a; cin >> a; T.push_back(a); } for (int i = N - 1; i >= 0; i--) { if (T[i] == A[i + 1] % 2) ; else { for (int j = 1; j * j <= i + 1; j++) { if ((i + 1) % j == 0) { A[j]++; if (j * j != i + 1) A[(i + 1) / j]++; } } b.push_back(i + 1); count++; } } reverse(b.begin(), b.end()); cout << count << endl; for (int i = 0; i < b.size(); i++) cout << b[i] << " " << flush; if (b.size() != 0) cout << endl; return 0; }
[ "call.arguments.change" ]
778,028
778,029
u526894223
cpp
p02972
#include <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < n; i++) #define REPR(i, n) for (int i = n; i >= 0; i--) #define FOR(i, m, n) for (int i = m; i < n; i++) #define FORR(i, m, n) for (int i = m; i >= n; i--) #define pb(a) push_back(a) #define mk(a, b) make_pair(a, b) #define ll long long #define INF 999999999 #define IOS \ cin.tie(0); \ ios::sync_with_stdio(false) using namespace std; typedef pair<int, int> P; typedef pair<int, P> PP; typedef pair<ll, ll> LP; typedef pair<ll, LP> LPP; int dy[] = {0, 0, 1, -1}; int dx[] = {1, -1, 0, 0}; int gcd(int a, int b) { return b ? gcd(b, a % b) : a; } int lcm(int a, int b) { return a / gcd(a, b) * b; } int main() { IOS; int N; cin >> N; vector<int> T; vector<int> b; int count = 0; vector<int> A(200020); for (int i = 0; i < N; i++) { int a; cin >> a; T.push_back(a); } for (int i = N - 1; i >= 0; i--) { if (T[i] == A[i + 1] % 2) ; else { for (int j = 1; j * j <= i + 1; j++) { if ((i + 1) % j == 0) { A[j]++; if (j * j != i + 1) A[(i + 1) / j]++; } } b.push_back(T[i]); count++; } } reverse(b.begin(), b.end()); cout << count << endl; for (int i = 0; i < b.size(); i++) cout << b[i] << " " << flush; if (b.size() != 0) cout << endl; return 0; }
#include <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < n; i++) #define REPR(i, n) for (int i = n; i >= 0; i--) #define FOR(i, m, n) for (int i = m; i < n; i++) #define FORR(i, m, n) for (int i = m; i >= n; i--) #define pb(a) push_back(a) #define mk(a, b) make_pair(a, b) #define ll long long #define INF 999999999 #define IOS \ cin.tie(0); \ ios::sync_with_stdio(false) using namespace std; typedef pair<int, int> P; typedef pair<int, P> PP; typedef pair<ll, ll> LP; typedef pair<ll, LP> LPP; int dy[] = {0, 0, 1, -1}; int dx[] = {1, -1, 0, 0}; int gcd(int a, int b) { return b ? gcd(b, a % b) : a; } int lcm(int a, int b) { return a / gcd(a, b) * b; } int main() { int N; cin >> N; vector<int> T; vector<int> b; int count = 0; vector<int> A(200020); for (int i = 0; i < N; i++) { int a; cin >> a; T.push_back(a); } for (int i = N - 1; i >= 0; i--) { if (T[i] == A[i + 1] % 2) ; else { for (int j = 1; j * j <= i + 1; j++) { if ((i + 1) % j == 0) { A[j]++; if (j * j != i + 1) A[(i + 1) / j]++; } } b.push_back(i + 1); count++; } } reverse(b.begin(), b.end()); cout << count << endl; for (int i = 0; i < b.size(); i++) cout << b[i] << " " << flush; if (b.size() != 0) cout << endl; return 0; }
[ "call.arguments.change" ]
778,030
778,029
u526894223
cpp
p02972
#include <bits/stdc++.h> using namespace std; #define rep(i, n) for (int i = 0; i < (n); i++) #define sz(x) int(x.size()) typedef long long ll; typedef pair<int, int> P; constexpr ll INF = (1LL << 55); constexpr int n_max = 2e5 + 1; int main() { int n; cin >> n; vector<int> a(n + 1); rep(i, n) cin >> a[i + 1]; vector<int> res, cnt(n_max, 0); for (int i = n; i > 0; i--) { int now = 0; for (int j = i * 2; j <= n; j++) now ^= cnt[j]; cnt[i] = now ^ a[i]; if (cnt[i]) res.emplace_back(i); } cout << res.size() << endl; for (auto e : res) cout << e << " "; cout << endl; return 0; }
#include <bits/stdc++.h> using namespace std; #define rep(i, n) for (int i = 0; i < (n); i++) #define sz(x) int(x.size()) typedef long long ll; typedef pair<int, int> P; constexpr ll INF = (1LL << 55); constexpr int n_max = 2e5 + 1; int main() { int n; cin >> n; vector<int> a(n + 1); rep(i, n) cin >> a[i + 1]; vector<int> res, cnt(n_max, 0); for (int i = n; i > 0; i--) { int now = 0; for (int j = i * 2; j <= n; j += i) now ^= cnt[j]; cnt[i] = now ^ a[i]; if (cnt[i]) res.emplace_back(i); } cout << res.size() << endl; for (auto e : res) cout << e << " "; cout << endl; return 0; }
[]
778,031
778,032
u108540384
cpp
p02972
#include <bits/stdc++.h> using namespace std; #define rep(i, n) for (int i = 0; i < (n); i++) #define sz(x) int(x.size()) typedef long long ll; typedef pair<int, int> P; constexpr ll INF = (1LL << 55); constexpr int n_max = 1e5 + 1; int main() { int n; cin >> n; vector<int> a(n + 1); rep(i, n) cin >> a[i + 1]; vector<int> res, cnt(n_max, 0); for (int i = n; i > 0; i--) { int now = 0; for (int j = i * 2; j <= n; j++) now ^= cnt[j]; cnt[i] = now ^ a[i]; if (cnt[i]) res.emplace_back(i); } cout << res.size() << endl; for (auto e : res) cout << e << " "; cout << endl; return 0; }
#include <bits/stdc++.h> using namespace std; #define rep(i, n) for (int i = 0; i < (n); i++) #define sz(x) int(x.size()) typedef long long ll; typedef pair<int, int> P; constexpr ll INF = (1LL << 55); constexpr int n_max = 2e5 + 1; int main() { int n; cin >> n; vector<int> a(n + 1); rep(i, n) cin >> a[i + 1]; vector<int> res, cnt(n_max, 0); for (int i = n; i > 0; i--) { int now = 0; for (int j = i * 2; j <= n; j += i) now ^= cnt[j]; cnt[i] = now ^ a[i]; if (cnt[i]) res.emplace_back(i); } cout << res.size() << endl; for (auto e : res) cout << e << " "; cout << endl; return 0; }
[ "literal.number.change", "expression.operation.binary.change" ]
778,033
778,032
u108540384
cpp
p02972
#include <bits/stdc++.h> using namespace std; #define rep(i, n) for (int i = 0; i < (n); i++) typedef long long ll; int table[200005]; int main() { int N; cin >> N; vector<int> a(N + 1); rep(i, N) { cin >> a[i + 1]; } vector<int> b(N + 1); vector<int> ans; for (int i = N; i > 0; i--) { int sum = 0; for (int j = i * 2; j <= N; j += i) { sum ^= b[j]; } b[i] = sum ^ a[i]; if (b[i]) ans.push_back(b[i]); } cout << ans.size() << endl; for (auto e : ans) { cout << e << " "; } cout << endl; return 0; }
#include <bits/stdc++.h> using namespace std; #define rep(i, n) for (int i = 0; i < (n); i++) typedef long long ll; int table[200005]; int main() { int N; cin >> N; vector<int> a(N + 1); rep(i, N) { cin >> a[i + 1]; } vector<int> b(N + 1); vector<int> ans; for (int i = N; i > 0; i--) { int sum = 0; for (int j = i * 2; j <= N; j += i) { sum ^= b[j]; } b[i] = sum ^ a[i]; if (b[i]) ans.push_back(i); } cout << ans.size() << endl; for (auto e : ans) { cout << e << " "; } cout << endl; return 0; }
[ "call.arguments.change" ]
778,034
778,035
u108540384
cpp
p02972
#include <bits/stdc++.h> #define rep(i, n) for (int i = 1; i <= (n); i++) using namespace std; typedef long long ll; int b[200005]; int main() { int n; cin >> n; vector<int> a(n + 1); rep(i, n) { cin >> a[i]; } vector<int> ans; for (int i = n; i > 0; i--) { int sum = 0; for (int j = i * 2; j <= n; j += i) { sum ^= a[j]; } b[i] = sum ^ a[i]; if (b[i]) ans.push_back(i); } cout << ans.size() << endl; for (auto e : ans) { cout << e << " "; } cout << endl; return 0; }
#include <bits/stdc++.h> #define rep(i, n) for (int i = 1; i <= (n); i++) using namespace std; typedef long long ll; int b[200005]; int main() { int n; cin >> n; vector<int> a(n + 1); rep(i, n) { cin >> a[i]; } vector<int> ans; for (int i = n; i > 0; i--) { int sum = 0; for (int j = i * 2; j <= n; j += i) { sum ^= b[j]; } b[i] = sum ^ a[i]; if (b[i]) ans.push_back(i); } cout << ans.size() << endl; for (auto e : ans) { cout << e << " "; } cout << endl; return 0; }
[ "assignment.value.change", "identifier.change" ]
778,036
778,037
u108540384
cpp
p02972
#include <algorithm> #include <climits> #include <cmath> #include <fstream> #include <iostream> #include <list> #include <map> #include <queue> #include <stack> #include <stdio.h> #include <string> #include <unordered_map> #include <vector> using namespace std; #define rep(i, n) for (int i = 0; i < n; ++i) #define ALL(v) v.begin(), v.end() typedef long long ll; int main() { int n; cin >> n; vector<int> a(n); rep(i, n) cin >> a[i]; vector<int> b(n); vector<int> ans; for (int i = n - 1; i >= 0; --i) { int sum = 0; for (int j = i; j < n; j += i + 1) { // cout<<j<<endl; sum += b[i]; } // cout<<sum<<":"<<a[i]<<endl; if (sum % 2 != a[i]) { b[i]++; ans.push_back(i + 1); } } cout << ans.size() << endl; rep(i, ans.size()) cout << ans[i] << endl; return 0; }
#include <algorithm> #include <climits> #include <cmath> #include <fstream> #include <iostream> #include <list> #include <map> #include <queue> #include <stack> #include <stdio.h> #include <string> #include <unordered_map> #include <vector> using namespace std; #define rep(i, n) for (int i = 0; i < n; ++i) #define ALL(v) v.begin(), v.end() typedef long long ll; int main() { int n; cin >> n; vector<int> a(n); rep(i, n) cin >> a[i]; vector<int> b(n); vector<int> ans; for (int i = n - 1; i >= 0; --i) { int sum = 0; for (int j = i; j < n; j += i + 1) { sum += b[j]; } // cout<<b[5]<<endl; // cout<<sum<<":"<<a[i]<<endl; if (sum % 2 != a[i]) { b[i]++; ans.push_back(i + 1); } } // rep(i,n)cout<<b[i]; cout << ans.size() << endl; rep(i, ans.size()) cout << ans[i] << endl; return 0; }
[ "assignment.value.change", "identifier.change", "variable_access.subscript.index.change" ]
778,038
778,039
u184929210
cpp
p02972
#include "bits/stdc++.h" #define rep(i, n) for (int i = 0; i < n; i++) using namespace std; using ll = long long; const ll MOD = 998244353; int main() { int N, t = 0; cin >> N; vector<int> a(N + 1), b(N / 2 + 1, 0), ans(N + 1); rep(i, N) cin >> a[i + 1]; for (int i = N; i > 0; i--) { int s = 0; for (int j = i * 2; j <= N; j += i) { s += a[j]; } ans[i] = (a[i] + s) % 2; t += ans[i]; } cout << t << endl; rep(i, N) { if (ans[i + 1] == 1) { cout << i + 1; t--; if (t == 0) cout << endl; else cout << " "; } } }
#include "bits/stdc++.h" #define rep(i, n) for (int i = 0; i < n; i++) using namespace std; using ll = long long; const ll MOD = 998244353; int main() { int N, t = 0; cin >> N; vector<int> a(N + 1), b(N / 2 + 1, 0), ans(N + 1); rep(i, N) cin >> a[i + 1]; for (int i = N; i > 0; i--) { int s = 0; for (int j = i * 2; j <= N; j += i) { s += ans[j]; } // cout << "i=" << i << " s=" << s << endl; ans[i] = (a[i] + s) % 2; t += ans[i]; } cout << t << endl; rep(i, N) { if (ans[i + 1] == 1) { cout << i + 1; t--; if (t == 0) cout << endl; else cout << " "; } } // rep(i, N) cout << ans[i + 1] << " "; // cout << endl; }
[ "assignment.value.change", "identifier.change" ]
778,040
778,041
u555962250
cpp
p02972
// // 2019/03/30 Ver1.10 // // Codeforces: ganariya // AtCoder: ganariya2525 // MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM // MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM // MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM // MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMHBYYYWMMMM#BYYTTTYWMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM // MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMB9O1==?????zzCC111>>;;;;;;;;;;;<?TMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM // MMMMMMMMMMMMMMMMMMMMMMMMMMMMMM9Olll=l======??????????>>>>>>;;;;;;;;;:;?TMMMMMMMMMMMMMMMMMMMMMMMMMMMM // MMMMMMMMMMMMMMMMMMMMMMMMMMM9ttlllllllll=l=======?????????>>>>>>;;;;;;;;;;?TMMMMMMMMMMMMMMMMMMMMMMMMM // MMMMMMMMMMMMMMMMMMMMMMMMBOttOtttttltlllllllll=======??????????>>>>>>>;;;;;;?TMMMMMMMMMMMMMMMMMMMMMMM // MMMMMMMMMMMMMMMMMMMMMMBttwOtttttttttttttlllllllll========?????????>>>>>>;;;;;<TMMMMMMMMMMMMMMMMMMMMM // MMMMMMMMMMMMMMMMMMMMBrwZrttttttttttttttttttlllllllllll======???????????>>>>>>;;?HMMMMMMMMMMMMMMMMMMM // MMMMMMMMMMMMMMMMMMMSw0trtrrtrtrttrtttttttttttttlllOllllll========????<<zz??>>>>>>ZMMMMMMMMMMMMMMMMMM // MMMMMMMMMMMMMMMMMMX0ttrtrOOttrttrttOOttttttttttttltwllllllllll========??wy?????>>>vZMMMMMMMMMMMMMMMM // MMMMMMMMMMMMMMMMM0ttrI+wV1rtttttttwZtttttttltttOwylOXOllllllllllll=l====1dkz???????vZdMMMMMMMMMMMMMM // MMMMMMMMMMMMMMMSrrwrtwZCjttttttttwSttOlllltllllwtXOlZkOlllllllllllllll==z+dk===?????X2JMMMMMMMMMMMMM // MMMMMMMMMMMMMBrtwwtrw0<jttttttttOXllOttltllttllOZwHOtXkyltlllllllllllllll<+XZ======?dk?JMMMMMMMMMMMM // MMMMMMMMMMMMStwdZtwXC<+ttttttOOOd6ltZlltllllttllStWWOOHWytttttltltOllltllz:zHllll===zX=?dMMMMMMMMMMM // MMMMMMMMMMBrwdKOtwW3;;zrttttwZwXRlldOllltltlltttwlXvktdXWytltttttttOttlttl<<dklllllllZ===dMMMMMMMMMM // MMMMMMMMM8tQM#ttwW3;;;1trttwSwfUOlORltllltlllllldtX>dktDOWOtlttltttOOttltO<;+WOllllllXlllzMMMMMMMMMM // MMMMMMMM9OdM#Ottd$;;;;;<?1z0OKjRltd0llltOllllllldZX>?WOw_WWOtttttttttOttI<;;<dkttttllllllldMMMMMMMMM // MMMMMMM9wMMMSttwS<;;;;>;;;J<j>(I<?U111zltllllllld0X>~dkwl(WkttlttlOOwWk<;;:;;zHttttttwOllllMMMMMMMMM // MMMMMMBdMMM8tttdI+zttttttdSXt~dlzXwlllzzOzzzzzlldkW<~?kOk~?sx++++jdHmH6+++<;;jdZtttttdkOtlldMMMMMMMM // MMMMM#dMMM#tttw0+tttttttdKdf((RsdfRllllldZllltlldWK~~_W0w_~OWOlOdgg9ZtOWOtttz+wktttttdpktttwMMMMMMMM // MMMMMWMMMMSlttdIttttttOdWHH>~(IzWDRll=llzRlllzlldk$>++dkd<~_XkdgH9tttttdktttt+OkrttrtdfpkttOMMMMMMMM // MMMMNWMMM#Zttlk=tttttOXWWd$_.(IdW1R=llll=SlllzOldK<_._(kd6+-(MM9lltttttrWktttztWZttrwXppWttrMMMMMMMM // MMMMNMMMM#lltwDzttllOXyW0X:..(OXk<Rl=ll=lwOlllOld3<``.(Rd>~?CdklllltttttXdXttzOWktrwwWpfpkrtMMMMMMMM // MMMMMMMMM@ltldIzlttOXyW$w$```(OyD(Rl==llldZ=llIlw;~```-Xd:~~~~UkylltttAyHdgSrzObRtOXwpfppWrrMMMMMMMM // MMMMMMMMM@llldtlllldVyW+d>```.wZ$ wl==lI=wRl=ll=w<```` // dd_..~~(RZXOQdggHH9ZwrzwHWrdXXppfppkrMMMMMMMM // MMMMMMMMM#llldlltlwyyyD(S-...,Wk] zI=l=llzWzl=l=P~```` // jZ``...~zQkH@MBUtrZtrtldHRdSdpfpffpkwMMMMMMMM // MMMMNMMMMNZllXtllldVyW3(Mf=<ONMHP~(k===l=zdk=lld3```...(C````..(M96lttttrrtrrtdHWHXpfpppfpRwMMMMMMMM // MMMMMMMMMMNzzWZllzyyyy(W@` =~MWK6 jz=lzlzvRz=lZ`.I+JgkWm&-. // `..(ZltlttttrtttrWWHppfppfpppSdMMMMMMMM MMMMMMMMMMMkAWRllzVyyS_(b // .MNHU-(Uz=lI={XkzO>.dVT7<TMHMNHHx-.(kwZyltttrtrrdHHpfppfpffpp0dMMMMMMMM // MMMMMMMMMMMMKyWzOzyyyk.`<! hdWMH]``(S==t=l(kX2 ?_` // WMMHH#HH+.XwkwOttttrwrZ~(HfpfpppfpWwXMMMMMMMM MMMMMMMMMMMMMHWROOyyyW;` `. // (WVM#b```(0=zzz wX!``` a.dM#NM@N(4WhXkXkWtttttwd3O_(HpffpfpfWwSMMMMMMMM // MMMMMMMMMMMMNZvWzXXyyXP```-_ ?o+?!````.4=Z=`(:```` HpbNNMHHH // (C=XXyWZWttrdwf:(>.dfppffppSXSMMMMMMMM // MMMMMMMMMMMMMRzuHzXyZXH.``````````````` ?zz ``````` ZKvTHHbWt `` // XZyyHZWOdSZ<::~`(fpfpfffXp0WMMMMMMM // MMMMMMMMMMMMMKzyyHvyZZW____.`````````````.I_```````` // ?nJzX7^````.WXWyyHyWKZ<:::_`Jffpfpfpfp0WMMMMMMM // MMMMMMMMMMMMM@zZyZWwWyXo-_~(~ ```````````` `````````````` // _`````.WXkyyVWmWc::<~ .HffppfffffkXMMMMMMM // MMMMMMMMMMMMMKzZZZZXkUXr~....```````....```````````` ... // ````..JXWWyyW83vXx~..WfffVfWVffffkdMMMMMMM // MMMMMMMMMMMMMRzZZZZZZZZb````````````<````````````./<~._<_.____`(WfdyW3<:~~(XWkVVVVVVVHVVVVV0dMMMMMMM // MMMMMMMMMMMMMSzZZZZZZZWX-```````````````````````````.......~~._j9jX=_~~_(XZyVHHkyyyyWHyyykykOMMMMMMM // MMMMMMMMMMMMMSzuuuuuZXWZW,```````````````````````````````.``..(3<! // ...JWyyXWyyyWHkyyWHyyyHyklMMMMMMM MMMMMMMMMMMMNXzuuuXXuXSuuXh,```````` .... // ```````````````````_~ .JWyyyyZyy0HyyZyyZyZXWZZZWHZIdMMMMMM // MMMMMMMMMMMMNwtuuuXkuXXuuuuXh,``````(:::~<?71(,``````````````.(UMNUkZZZZZZZHZZ0ZZZZZWWZZZWNXIdMMMMMM // MMMMMMMMMMMMNKOzuzXkuXuuuuuXuXW, ```` // _~~~:~~(}```````````.(YC;::<kCfZZZZXO#ZZVZZZZZMZZuuMMNXzMMMMMM // MMMMMMMMMMMMHKOzzuXkzdzzzzuXXzuuU&.``````````````````` // .JY>::::;;J=:dZuZuZd#uuruuuud#uuuXMMMNXdMMMMM // MMMMMMMMMMMMMNOvzzXkvMRzzzzXKzuzzzXh, // `````````````..JC<;:;;:;;+7<:~(HHuXIdNuuzuuuXMSuuuWMMMMROMMMMM // MMMMMMMMMMMMMNvvvrdkvM#vzzzzHzzzzzuzzUG. ``` // ...JdY<:;:;:::;;+v<~~~:(HpHmzMNXZzuzzd#zzzdMMMMMMRdMMMM // MMMMMMMMMMMMMNwrrvdRrMNwvvvvdRvvvzwkzzzzXWWHY=~~O+::::::::<+<~~~~~~~dppppWMMkZzzzwM#zzdMMMMMMMMNMMMM // MMMMMMMMMMMMMM#rrrwRrMMbOrrOZNkrvvvXwvvvvvwX;.~._W_:::::(?!~~~~~~~~(HpppppppHWdvwM#XwdMMMMMMMMMMNMMM // MMMMMMMMMMMMMMNyrrrRrWMMmzOrzdNyrrrZNvrwQWWfb....(r~~_J>_.....~.~~-dpfpffpfpppWHHMNdMMMMMMMMMMMMMMMM // MMMMMMMMMMMMMMMNrtrStdMMMNxzrzMNmrrrdNWfVfffP._-.(~_J!............JpfpffpfpfffpppWNppppHMMMMMMMMMMMM // MMMMMMMMMMMMMMMMNOtXtdMMMMMNxzZMMNmgHyVVVVVW%..?/(.,(x-..........(HfffpffpffpffWHHffpffppfVyyWMMMMMM // include //------------------------------------------ #include <algorithm> #include <bitset> #include <cctype> #include <climits> #include <cmath> #include <complex> #include <cstdio> #include <cstdlib> #include <cstring> #include <ctime> #include <deque> #include <functional> #include <iomanip> #include <iostream> #include <list> #include <map> #include <numeric> #include <queue> #include <random> #include <regex> #include <set> #include <sstream> #include <stack> #include <string> #include <unordered_map> #include <unordered_set> #include <utility> #include <vector> using namespace std; // typedef //------------------------------------------ typedef long long LL; typedef vector<int> VI; typedef vector<bool> VB; typedef vector<char> VC; typedef vector<double> VD; typedef vector<string> VS; typedef vector<LL> VLL; typedef vector<VI> VVI; typedef vector<VB> VVB; typedef vector<VS> VVS; typedef vector<VLL> VVLL; typedef vector<VVI> VVVI; typedef vector<VVLL> VVVLL; typedef pair<int, int> PII; typedef pair<LL, LL> PLL; typedef pair<int, string> PIS; typedef pair<string, int> PSI; typedef pair<string, string> PSS; typedef vector<PII> VPII; typedef vector<PLL> VPLL; typedef vector<VPII> VVPII; typedef vector<VPLL> VVPLL; typedef vector<VS> VVS; typedef map<int, int> MII; typedef map<LL, LL> MLL; typedef map<string, int> MSI; typedef map<int, string> MIS; typedef __int128 Lint; //数値・文字列 //------------------------------------------ inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; } inline LL toLongLong(string s) { LL v; istringstream sin(s); sin >> v; return v; } Lint toLint(const string s) { Lint ret = 0; for (int i = 0; i < s.length(); i++) if ('0' <= s[i] && s[i] <= '9') ret = 10 * ret + s[i] - '0'; return ret; } template <class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); } inline VC toVC(string s) { VC data(s.begin(), s.end()); return data; } vector<string> SPRIT(const string &s, const string &delim) { vector<string> result; string::size_type pos = 0; while (pos != string::npos) { string::size_type p = s.find(delim, pos); if (p == string::npos) { result.push_back(s.substr(pos)); break; } else { result.push_back(s.substr(pos, p - pos)); } pos = p + delim.size(); } return result; } string TRIM(const string &str, const char *trimCharacterList = " \t\v\r\n") { string result; string::size_type left = str.find_first_not_of(trimCharacterList); if (left != string::npos) { string::size_type right = str.find_last_not_of(trimCharacterList); result = str.substr(left, right - left + 1); } return result; } string REPLACE_STRING(const string source, const string find, const string alt) { string result = source; string::size_type pos = 0; while (pos = result.find(find, pos), pos != string::npos) { result.replace(pos, find.length(), alt); pos += alt.length(); } return result; } template <typename T> bool VECTOR_EXISTS(vector<T> vec, T data) { auto itr = std::find(vec.begin(), vec.end(), data); size_t index = distance(vec.begin(), itr); if (index != vec.size()) return true; else return false; } template <typename T> void VECTOR_REMOVE_VALUE_ALL(vector<T> &vec, T data) { vec.erase(remove(vec.begin(), vec.end(), data), vec.end()); } template <typename T> vector<T> VECTOR_REMOVE_VALUE_ALL_FAST(vector<T> vec, T data) { vector<T> vec2; for (auto &x : vec) if (x != data) vec2.push_back(x); return vec2; } bool REG_MATCH(string const &text, regex const &re) { bool result = regex_match(text, re); return result; } bool REG_MATCH(string const &text, smatch &match, regex const &re) { bool result = regex_match(text, match, re); return result; } smatch REG_SEARCH(string const &text, regex const &re) { smatch m; regex_search(text, m, re); return m; } vector<smatch> REG_ALL_SEARCH(string const &text, regex const &re) { vector<smatch> matchs; sregex_iterator iter(text.cbegin(), text.cend(), re); sregex_iterator end; for (; iter != end; iter++) matchs.push_back(*iter); return matchs; } string REG_REPLACE(string const &text, regex const &re, string const &replace) { string result = regex_replace(text, re, replace, regex_constants::format_first_only); return result; } string REG_ALL_REPLACE(string const &text, regex const &re, string const &replace) { string result = regex_replace(text, re, replace); return result; } template <typename T> vector<T> COMPRESS(vector<T> v) { sort(v.begin(), v.end()); v.erase(unique(v.begin(), v.end()), v.end()); return v; } template <typename T> pair<map<T, int>, map<int, T>> MAPPING(const vector<T> v) { map<T, int> zip; map<int, T> unzip; for (int i = 0; i < v.size(); i++) zip[v[i]] = i; for (int i = 0; i < v.size(); i++) unzip[i] = v[i]; return make_pair(zip, unzip); } template <typename T> vector<pair<T, int>> RUN_LENGTH(const vector<T> &v) { vector<pair<T, int>> ret; int len = v.size(); for (int i = 0, j = 0; i < len; i = j) { while (j < len && v[i] == v[j]) j++; ret.push_back(make_pair(v[i], j - i)); } return ret; } template <typename T, typename U, typename V, typename W> auto operator+(const std::pair<T, U> &l, const std::pair<V, W> &r) -> std::pair<decltype(l.first + r.first), decltype(l.second + r.second)> { return {l.first + r.first, l.second + r.second}; } template <typename T, typename U, typename V, typename W> auto operator-(const std::pair<T, U> &l, const std::pair<V, W> &r) -> std::pair<decltype(l.first - r.first), decltype(l.second - r.second)> { return {l.first - r.first, l.second - r.second}; } ostream &operator<<(ostream &dest, __int128_t value) { ostream::sentry s(dest); if (s) { __uint128_t tmp = value < 0 ? -value : value; char buffer[128]; char *d = std::end(buffer); do { --d; *d = "0123456789"[tmp % 10]; tmp /= 10; } while (tmp != 0); if (value < 0) { --d; *d = '-'; } int len = std::end(buffer) - d; if (dest.rdbuf()->sputn(d, len) != len) { dest.setstate(ios_base::badbit); } } return dest; } #define UPPER(s) transform((s).begin(), (s).end(), (s).begin(), ::toupper) #define LOWER(s) transform((s).begin(), (s).end(), (s).begin(), ::tolower) //四捨五入 nLen=小数点第n位にする //------------------------------------------ //切り上げ double ceil_n(double dIn, long long nLen) { double dOut; dOut = dIn * pow(10.0, nLen); dOut = (double)(long long)(dOut + 0.9); return dOut * pow(10.0, -nLen); } //切り捨て double floor_n(double dIn, long long nLen) { double dOut; dOut = dIn * pow(10.0, nLen); dOut = (double)(long long)(dOut); return dOut * pow(10.0, -nLen); } //四捨五入 double round_n(double dIn, long long nLen) { double dOut; dOut = dIn * pow(10.0, nLen); dOut = (double)(long long)(dOut + 0.5); return dOut * pow(10.0, -nLen); } // n桁目の数の取得 int take_a_n(LL num, int n) { string str = toString(num); return str[str.length() - n] - '0'; } int bitcount32(int bits) { bits = (bits & 0x55555555) + (bits >> 1 & 0x55555555); bits = (bits & 0x33333333) + (bits >> 2 & 0x33333333); bits = (bits & 0x0f0f0f0f) + (bits >> 4 & 0x0f0f0f0f); bits = (bits & 0x00ff00ff) + (bits >> 8 & 0x00ff00ff); return (bits & 0x0000ffff) + (bits >> 16 & 0x0000ffff); } //整数を2進数表記したときの1の個数を返す LL bitcount64(LL bits) { bits = (bits & 0x5555555555555555) + (bits >> 1 & 0x5555555555555555); bits = (bits & 0x3333333333333333) + (bits >> 2 & 0x3333333333333333); bits = (bits & 0x0f0f0f0f0f0f0f0f) + (bits >> 4 & 0x0f0f0f0f0f0f0f0f); bits = (bits & 0x00ff00ff00ff00ff) + (bits >> 8 & 0x00ff00ff00ff00ff); bits = (bits & 0x0000ffff0000ffff) + (bits >> 16 & 0x0000ffff0000ffff); return (bits & 0x00000000ffffffff) + (bits >> 32 & 0x00000000ffffffff); } // comparison //------------------------------------------ #define C_MAX(a, b) ((a) > (b) ? (a) : (b)) #define C_MIN(a, b) ((a) < (b) ? (a) : (b)) #define C_ABS(a, b) ((a) < (b) ? (b) - (a) : (a) - (b)) template <class T1, class T2> inline bool chmin(T1 &a, T2 b) { if (a > b) { a = b; return true; } return false; } template <class T1, class T2> inline bool chmax(T1 &a, T2 b) { if (a < b) { a = b; return true; } return false; } // container util //------------------------------------------ #define ALL(a) (a).begin(), (a).end() #define RALL(a) (a).rbegin(), (a).rend() #define SZ(a) int((a).size()) #define EACH(i, arr) \ for (typeof((arr).begin()) i = (arr).begin(); i != (arr).end(); ++i) #define EXIST(str, e) ((str).find(e) != (str).end()) #define COUNT(arr, v) count((arr).begin(), (arr).end(), v) #define SEARCH(v, w) search((v).begin(), (v).end(), (w).begin(), (w).end()) #define B_SEARCH(arr, v) binary_search((arr).begin(), (arr).end(), v) #define SORT(c) sort((c).begin(), (c).end()) #define RSORT(c) sort((c).rbegin(), (c).rend()) #define REVERSE(c) reverse((c).begin(), (c).end()) #define ROTATE_LEFT(arr, c) \ rotate((arr).begin(), (arr).begin() + (c), (arr).end()) #define ROTATE_RIGHT(arr, c) \ rotate((arr).rbegin(), (arr).rbegin() + (c), (arr).rend()) #define SUMI(arr) accumulate((arr).begin(), (arr).end(), 0) #define SUMD(arr) accumulate((arr).begin(), (arr).end(), 0.) #define SUMLL(arr) accumulate((arr).begin(), (arr).end(), 0LL) #define SUMS(arr) accumulate((arr).begin(), (arr).end(), string()) #define MULD(arr) \ accumulate((arr).begin(), (arr).end(), 1., multiplies<double>()) #define MULLL(arr) \ accumulate((arr).begin(), (arr).end(), 1LL, multiplies<long long>()) #define UB(arr, n) upper_bound((arr).begin(), (arr).end(), n) #define LB(arr, n) lower_bound((arr).begin(), (arr).end(), n) #define OF_ALL(arr, func) all_of((arr).begin(), (arr).end(), (func)) #define OF_NONE(arr, func) none_of((arr).begin(), (arr).end(), (func)) #define OF_ANY(arr, func) any_of((arr).begin(), (arr).end(), (func)) #define PB push_back #define MP make_pair #define ft first #define sd second // input output //------------------------------------------ #define GL(s) getline(cin, (s)) #define INIT() \ std::ios::sync_with_stdio(false); \ std::cin.tie(0); #define OUT(d) std::cout << (d) #define OUT_L(d) std::cout << (d) << endl #define FOUT(n, data) std::cout << std::fixed << std::setprecision(n) << (data) #define FOUT_L(n, data) \ std::cout << std::fixed << std::setprecision(n) << (data) << "\n" #define EL() printf("\n") #define SHOW_VECTOR(v) \ { \ std::cerr << #v << "\t:"; \ for (const auto &xxx : v) { \ std::cerr << xxx << " "; \ } \ std::cerr << "\n"; \ } #define SHOW_MAP(v) \ { \ std::cerr << #v << endl; \ for (const auto &xxx : v) { \ std::cerr << xxx.first << " " << xxx.second << "\n"; \ } \ } #define Yes() printf("Yes\n") #define No() printf("No\n") #define YES() printf("YES\n") #define NO() printf("NO\n") #define Yay() printf("Yay!\n") #define Nnn() printf(":(\n") template <typename T1, typename T2> istream &operator>>(istream &in, pair<T1, T2> &p) { in >> p.first >> p.second; return in; } template <typename T> istream &operator>>(istream &in, vector<T> &v) { for (auto &x : v) in >> x; return in; } istream &operator>>(istream &in, Lint &d) { string s; cin >> s; Lint tmp = 0; for (int i = 0; i < s.length(); i++) if ('0' <= s[i] && s[i] <= '9') tmp = 10 * tmp + s[i] - '0'; d = tmp; return in; } template <typename T1, typename T2> ostream &operator<<(ostream &out, const std::pair<T1, T2> &p) { out << "[" << p.first << ", " << p.second << "]" << "\n"; return out; } // repetition //------------------------------------------ #define FOR(i, a, b) for (int i = (a); i < (b); ++i) #define RFOR(i, a, b) for (int i = (b)-1; i >= (a); --i) #define REP(i, n) FOR(i, 0, n) #define RREP(i, n) for (int i = n - 1; i >= 0; i--) #define FORLL(i, a, b) for (LL i = LL(a); i < LL(b); ++i) #define RFORLL(i, a, b) for (LL i = LL(b) - 1; i >= LL(a); --i) #define REPLL(i, n) for (LL i = 0; i < LL(n); ++i) #define RREPLL(i, n) for (LL i = LL(n) - 1; i >= 0; --i) #define FOREACH(x, arr) for (auto &(x) : (arr)) #define FORITER(x, arr) for (auto(x) = (arr).begin(); (x) != (arr).end(); ++(x)) // constant //-------------------------------------------- const double EPS = 1e-10; const double PI = acos(-1.0); const int dx[] = {-1, 0, 1, 0}; const int dy[] = {0, 1, 0, -1}; // math //-------------------------------------------- // min <= aim <= max template <typename T> inline bool BETWEEN(const T aim, const T min, const T max) { if (min <= aim && aim <= max) { return true; } else { return false; } } template <typename T1, typename T2> inline bool IS_OUT(const T1 toY, const T1 toX, const T2 H, const T2 W) { return (toY < 0 || toY >= H || toX < 0 || toX >= W); } template <class T> inline T SQR(const T x) { return x * x; } template <class T1, class T2> inline T1 POW(const T1 x, const T2 y) { if (!y) return 1; else if ((y & 1) == 0) { return SQR(POW(x, y >> 1)); } else return POW(x, y ^ 1) * x; } template <typename T> constexpr T ABS(T x) { return x < 0 ? -x : x; } // partial_permutation nPr 順列 // first・・最初の数 // middle・・r(取り出す数) // last・・n(全体数) template <class Iter> bool next_partial_permutation(Iter first, Iter middle, Iter last) { reverse(middle, last); return next_permutation(first, last); } // combination nCr 組み合わせ // first1・・最初の数 // last1==first2・・r(取り出す数) // last2・・n(全体数) template <class Iter> bool next_combination(Iter first1, Iter last1, Iter first2, Iter last2) { if ((first1 == last1) || (first2 == last2)) { return false; } Iter m1 = last1; Iter m2 = last2; --m2; while (--m1 != first1 && !(*m1 < *m2)) { } bool result = (m1 == first1) && !(*first1 < *m2); if (!result) { while (first2 != m2 && !(*m1 < *first2)) { ++first2; } first1 = m1; std::iter_swap(first1, first2); ++first1; ++first2; } if ((first1 != last1) && (first2 != last2)) { m1 = last1; m2 = first2; while ((m1 != first1) && (m2 != last2)) { std::iter_swap(--m1, m2); ++m2; } std::reverse(first1, m1); std::reverse(first1, last1); std::reverse(m2, last2); std::reverse(first2, last2); } return !result; } // numeric_law //-------------------------------------------- template <typename T> constexpr bool ODD(T x) { return x % 2 != 0; } template <typename T> constexpr bool EVEN(T x) { return x % 2 == 0; } //最大公約数 template <class T> inline T GCD(const T x, const T y) { if (x < 0) return GCD(-x, y); if (y < 0) return GCD(x, -y); return (!y) ? x : GCD(y, x % y); } //最小公倍数 template <class T> inline T LCM(const T x, const T y) { if (x < 0) return LCM(-x, y); if (y < 0) return LCM(x, -y); return x * (y / GCD(x, y)); } // ax + by = gcd(a, b) // x,yが変数に格納される template <class T> inline T EXTGCD(const T a, const T b, T &x, T &y) { if (a < 0) { T d = EXTGCD(-a, b, x, y); x = -x; return d; } if (b < 0) { T d = EXTGCD(a, -b, x, y); y = -y; return d; } if (!b) { x = 1; y = 0; return a; } else { T d = EXTGCD(b, a % b, x, y); T t = x; x = y; y = t - (a / b) * y; return d; } } // mの世界でのaの逆元 // gce(a, m) = 1 template <class T> inline T INV_MOD(const T a, const T m) { T x, y; EXTGCD(a, m, x, y); return (x + m) % m; } template <class T> inline bool ISPRIME(const T x) { if (x <= 1) return false; for (T i = 2; i * i <= x; i++) if (x % i == 0) return false; return true; } template <class T> VB ERATOSTHENES(const T n) { VB arr(n + 1, true); arr[0] = arr[1] = false; for (T i = 2; i * i <= n; i++) { if (arr[i]) { for (T j = i * 2LL; j <= n; j += i) { arr[j] = false; } } } return arr; } // a <= x < b の素数を返す template <typename T> VB ERATOSTHENES(const T a, const T b) { VB small = ERATOSTHENES(b); VB prime(b - a, true); for (T i = 2; i * i <= b; i++) { if (small[i]) { for (T j = max(2LL, (a + i - 1) / i) * i; j < b; j += i) { prime[j - a] = false; } } } return prime; } // nの約数 template <typename T> vector<T> DIVISOR(T n) { vector<T> v; for (T i = 1; i * i <= n; ++i) { if (n % i == 0) { v.push_back(i); if (i != n / i) { v.push_back(n / i); } } } sort(v.begin(), v.end()); return v; } // nまでのすべての約数 template <typename T> vector<vector<T>> DIVISOR_ALL(T n) { vector<vector<T>> res(n + 1); for (T i = 1; i <= n; i++) { for (T j = i; j <= n; j += i) { res[j].push_back(i); } } return res; } template <typename T> vector<pair<T, T>> FACTORIZATION(T x) { vector<pair<T, LL>> ans; for (T i = 2; i * i <= x; i++) { if (x % i == 0) { T count = 0; while (x % i == 0) { count++; x /= i; } ans.push_back(MP(i, count)); } } if (x != 1) ans.push_back(MP(x, 1)); return ans; } LL POW_MOD(LL N, LL P, LL M) { LL ret = 1; while (P > 0) { if (P & 1LL) ret = (ret * N) % M; N = (N * N) % M; P >>= 1LL; } return ret; } template <typename T> inline T NCR(T n, T r) { if (r > n - r) r = n - r; T ans = 1LL; for (T i = 0; i < r; i++) { ans = ans * (n - i) / (i + 1); } return ans; } LL NCR_MOD(LL n, LL r, LL M) { if (r > n - r) return NCR_MOD(n, n - r, M); LL numerator = 1LL; //分子 LL denominator = 1LL; //分母 for (LL i = 0; i < r; i++) { numerator *= (n - i); numerator %= M; denominator *= (i + 1); denominator %= M; } return numerator * POW_MOD(denominator, M - 2, M) % M; } // confirmation //-------------------------------------------- // clear memory #define CLR(arr, d) memset((arr), (d), sizeof(arr)) // debug #define dump(x) cerr << #x << " = " << (x) << endl; #define debug(x) \ cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" \ << " " << endl; // 2019-04-14 //~~~~~~~~~~~~~~~~~~~~~_(^~^ 」 ∠)_~~~~~~~~~~~~~~~~~~~~~ constexpr LL MAX = 200010; int main() { LL N; cin >> N; VLL a(N); cin >> a; VLL b(MAX, 0); auto divisors = DIVISOR_ALL(N); VLL ans(N, 0); for (LL i = N - 1; i >= 0; i--) { LL d = i + 1; if ((a[i] + b[i]) % 2 == 0) { continue; } else { ans[i] = 1; REP(j, divisors[i].size()) { LL k = divisors[i][j]; b[k]++; } } } LL sum = SUMLL(ans); cout << sum << endl; for (int i = 0; i < N; i++) { if (ans[i] == 1) { cout << i + 1 << " "; } } return 0; }
// // 2019/03/30 Ver1.10 // // Codeforces: ganariya // AtCoder: ganariya2525 // MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM // MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM // MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM // MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMHBYYYWMMMM#BYYTTTYWMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM // MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMB9O1==?????zzCC111>>;;;;;;;;;;;<?TMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM // MMMMMMMMMMMMMMMMMMMMMMMMMMMMMM9Olll=l======??????????>>>>>>;;;;;;;;;:;?TMMMMMMMMMMMMMMMMMMMMMMMMMMMM // MMMMMMMMMMMMMMMMMMMMMMMMMMM9ttlllllllll=l=======?????????>>>>>>;;;;;;;;;;?TMMMMMMMMMMMMMMMMMMMMMMMMM // MMMMMMMMMMMMMMMMMMMMMMMMBOttOtttttltlllllllll=======??????????>>>>>>>;;;;;;?TMMMMMMMMMMMMMMMMMMMMMMM // MMMMMMMMMMMMMMMMMMMMMMBttwOtttttttttttttlllllllll========?????????>>>>>>;;;;;<TMMMMMMMMMMMMMMMMMMMMM // MMMMMMMMMMMMMMMMMMMMBrwZrttttttttttttttttttlllllllllll======???????????>>>>>>;;?HMMMMMMMMMMMMMMMMMMM // MMMMMMMMMMMMMMMMMMMSw0trtrrtrtrttrtttttttttttttlllOllllll========????<<zz??>>>>>>ZMMMMMMMMMMMMMMMMMM // MMMMMMMMMMMMMMMMMMX0ttrtrOOttrttrttOOttttttttttttltwllllllllll========??wy?????>>>vZMMMMMMMMMMMMMMMM // MMMMMMMMMMMMMMMMM0ttrI+wV1rtttttttwZtttttttltttOwylOXOllllllllllll=l====1dkz???????vZdMMMMMMMMMMMMMM // MMMMMMMMMMMMMMMSrrwrtwZCjttttttttwSttOlllltllllwtXOlZkOlllllllllllllll==z+dk===?????X2JMMMMMMMMMMMMM // MMMMMMMMMMMMMBrtwwtrw0<jttttttttOXllOttltllttllOZwHOtXkyltlllllllllllllll<+XZ======?dk?JMMMMMMMMMMMM // MMMMMMMMMMMMStwdZtwXC<+ttttttOOOd6ltZlltllllttllStWWOOHWytttttltltOllltllz:zHllll===zX=?dMMMMMMMMMMM // MMMMMMMMMMBrwdKOtwW3;;zrttttwZwXRlldOllltltlltttwlXvktdXWytltttttttOttlttl<<dklllllllZ===dMMMMMMMMMM // MMMMMMMMM8tQM#ttwW3;;;1trttwSwfUOlORltllltlllllldtX>dktDOWOtlttltttOOttltO<;+WOllllllXlllzMMMMMMMMMM // MMMMMMMM9OdM#Ottd$;;;;;<?1z0OKjRltd0llltOllllllldZX>?WOw_WWOtttttttttOttI<;;<dkttttllllllldMMMMMMMMM // MMMMMMM9wMMMSttwS<;;;;>;;;J<j>(I<?U111zltllllllld0X>~dkwl(WkttlttlOOwWk<;;:;;zHttttttwOllllMMMMMMMMM // MMMMMMBdMMM8tttdI+zttttttdSXt~dlzXwlllzzOzzzzzlldkW<~?kOk~?sx++++jdHmH6+++<;;jdZtttttdkOtlldMMMMMMMM // MMMMM#dMMM#tttw0+tttttttdKdf((RsdfRllllldZllltlldWK~~_W0w_~OWOlOdgg9ZtOWOtttz+wktttttdpktttwMMMMMMMM // MMMMMWMMMMSlttdIttttttOdWHH>~(IzWDRll=llzRlllzlldk$>++dkd<~_XkdgH9tttttdktttt+OkrttrtdfpkttOMMMMMMMM // MMMMNWMMM#Zttlk=tttttOXWWd$_.(IdW1R=llll=SlllzOldK<_._(kd6+-(MM9lltttttrWktttztWZttrwXppWttrMMMMMMMM // MMMMNMMMM#lltwDzttllOXyW0X:..(OXk<Rl=ll=lwOlllOld3<``.(Rd>~?CdklllltttttXdXttzOWktrwwWpfpkrtMMMMMMMM // MMMMMMMMM@ltldIzlttOXyW$w$```(OyD(Rl==llldZ=llIlw;~```-Xd:~~~~UkylltttAyHdgSrzObRtOXwpfppWrrMMMMMMMM // MMMMMMMMM@llldtlllldVyW+d>```.wZ$ wl==lI=wRl=ll=w<```` // dd_..~~(RZXOQdggHH9ZwrzwHWrdXXppfppkrMMMMMMMM // MMMMMMMMM#llldlltlwyyyD(S-...,Wk] zI=l=llzWzl=l=P~```` // jZ``...~zQkH@MBUtrZtrtldHRdSdpfpffpkwMMMMMMMM // MMMMNMMMMNZllXtllldVyW3(Mf=<ONMHP~(k===l=zdk=lld3```...(C````..(M96lttttrrtrrtdHWHXpfpppfpRwMMMMMMMM // MMMMMMMMMMNzzWZllzyyyy(W@` =~MWK6 jz=lzlzvRz=lZ`.I+JgkWm&-. // `..(ZltlttttrtttrWWHppfppfpppSdMMMMMMMM MMMMMMMMMMMkAWRllzVyyS_(b // .MNHU-(Uz=lI={XkzO>.dVT7<TMHMNHHx-.(kwZyltttrtrrdHHpfppfpffpp0dMMMMMMMM // MMMMMMMMMMMMKyWzOzyyyk.`<! hdWMH]``(S==t=l(kX2 ?_` // WMMHH#HH+.XwkwOttttrwrZ~(HfpfpppfpWwXMMMMMMMM MMMMMMMMMMMMMHWROOyyyW;` `. // (WVM#b```(0=zzz wX!``` a.dM#NM@N(4WhXkXkWtttttwd3O_(HpffpfpfWwSMMMMMMMM // MMMMMMMMMMMMNZvWzXXyyXP```-_ ?o+?!````.4=Z=`(:```` HpbNNMHHH // (C=XXyWZWttrdwf:(>.dfppffppSXSMMMMMMMM // MMMMMMMMMMMMMRzuHzXyZXH.``````````````` ?zz ``````` ZKvTHHbWt `` // XZyyHZWOdSZ<::~`(fpfpfffXp0WMMMMMMM // MMMMMMMMMMMMMKzyyHvyZZW____.`````````````.I_```````` // ?nJzX7^````.WXWyyHyWKZ<:::_`Jffpfpfpfp0WMMMMMMM // MMMMMMMMMMMMM@zZyZWwWyXo-_~(~ ```````````` `````````````` // _`````.WXkyyVWmWc::<~ .HffppfffffkXMMMMMMM // MMMMMMMMMMMMMKzZZZZXkUXr~....```````....```````````` ... // ````..JXWWyyW83vXx~..WfffVfWVffffkdMMMMMMM // MMMMMMMMMMMMMRzZZZZZZZZb````````````<````````````./<~._<_.____`(WfdyW3<:~~(XWkVVVVVVVHVVVVV0dMMMMMMM // MMMMMMMMMMMMMSzZZZZZZZWX-```````````````````````````.......~~._j9jX=_~~_(XZyVHHkyyyyWHyyykykOMMMMMMM // MMMMMMMMMMMMMSzuuuuuZXWZW,```````````````````````````````.``..(3<! // ...JWyyXWyyyWHkyyWHyyyHyklMMMMMMM MMMMMMMMMMMMNXzuuuXXuXSuuXh,```````` .... // ```````````````````_~ .JWyyyyZyy0HyyZyyZyZXWZZZWHZIdMMMMMM // MMMMMMMMMMMMNwtuuuXkuXXuuuuXh,``````(:::~<?71(,``````````````.(UMNUkZZZZZZZHZZ0ZZZZZWWZZZWNXIdMMMMMM // MMMMMMMMMMMMNKOzuzXkuXuuuuuXuXW, ```` // _~~~:~~(}```````````.(YC;::<kCfZZZZXO#ZZVZZZZZMZZuuMMNXzMMMMMM // MMMMMMMMMMMMHKOzzuXkzdzzzzuXXzuuU&.``````````````````` // .JY>::::;;J=:dZuZuZd#uuruuuud#uuuXMMMNXdMMMMM // MMMMMMMMMMMMMNOvzzXkvMRzzzzXKzuzzzXh, // `````````````..JC<;:;;:;;+7<:~(HHuXIdNuuzuuuXMSuuuWMMMMROMMMMM // MMMMMMMMMMMMMNvvvrdkvM#vzzzzHzzzzzuzzUG. ``` // ...JdY<:;:;:::;;+v<~~~:(HpHmzMNXZzuzzd#zzzdMMMMMMRdMMMM // MMMMMMMMMMMMMNwrrvdRrMNwvvvvdRvvvzwkzzzzXWWHY=~~O+::::::::<+<~~~~~~~dppppWMMkZzzzwM#zzdMMMMMMMMNMMMM // MMMMMMMMMMMMMM#rrrwRrMMbOrrOZNkrvvvXwvvvvvwX;.~._W_:::::(?!~~~~~~~~(HpppppppHWdvwM#XwdMMMMMMMMMMNMMM // MMMMMMMMMMMMMMNyrrrRrWMMmzOrzdNyrrrZNvrwQWWfb....(r~~_J>_.....~.~~-dpfpffpfpppWHHMNdMMMMMMMMMMMMMMMM // MMMMMMMMMMMMMMMNrtrStdMMMNxzrzMNmrrrdNWfVfffP._-.(~_J!............JpfpffpfpfffpppWNppppHMMMMMMMMMMMM // MMMMMMMMMMMMMMMMNOtXtdMMMMMNxzZMMNmgHyVVVVVW%..?/(.,(x-..........(HfffpffpffpffWHHffpffppfVyyWMMMMMM // include //------------------------------------------ #include <algorithm> #include <bitset> #include <cctype> #include <climits> #include <cmath> #include <complex> #include <cstdio> #include <cstdlib> #include <cstring> #include <ctime> #include <deque> #include <functional> #include <iomanip> #include <iostream> #include <list> #include <map> #include <numeric> #include <queue> #include <random> #include <regex> #include <set> #include <sstream> #include <stack> #include <string> #include <unordered_map> #include <unordered_set> #include <utility> #include <vector> using namespace std; // typedef //------------------------------------------ typedef long long LL; typedef vector<int> VI; typedef vector<bool> VB; typedef vector<char> VC; typedef vector<double> VD; typedef vector<string> VS; typedef vector<LL> VLL; typedef vector<VI> VVI; typedef vector<VB> VVB; typedef vector<VS> VVS; typedef vector<VLL> VVLL; typedef vector<VVI> VVVI; typedef vector<VVLL> VVVLL; typedef pair<int, int> PII; typedef pair<LL, LL> PLL; typedef pair<int, string> PIS; typedef pair<string, int> PSI; typedef pair<string, string> PSS; typedef vector<PII> VPII; typedef vector<PLL> VPLL; typedef vector<VPII> VVPII; typedef vector<VPLL> VVPLL; typedef vector<VS> VVS; typedef map<int, int> MII; typedef map<LL, LL> MLL; typedef map<string, int> MSI; typedef map<int, string> MIS; typedef __int128 Lint; //数値・文字列 //------------------------------------------ inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; } inline LL toLongLong(string s) { LL v; istringstream sin(s); sin >> v; return v; } Lint toLint(const string s) { Lint ret = 0; for (int i = 0; i < s.length(); i++) if ('0' <= s[i] && s[i] <= '9') ret = 10 * ret + s[i] - '0'; return ret; } template <class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); } inline VC toVC(string s) { VC data(s.begin(), s.end()); return data; } vector<string> SPRIT(const string &s, const string &delim) { vector<string> result; string::size_type pos = 0; while (pos != string::npos) { string::size_type p = s.find(delim, pos); if (p == string::npos) { result.push_back(s.substr(pos)); break; } else { result.push_back(s.substr(pos, p - pos)); } pos = p + delim.size(); } return result; } string TRIM(const string &str, const char *trimCharacterList = " \t\v\r\n") { string result; string::size_type left = str.find_first_not_of(trimCharacterList); if (left != string::npos) { string::size_type right = str.find_last_not_of(trimCharacterList); result = str.substr(left, right - left + 1); } return result; } string REPLACE_STRING(const string source, const string find, const string alt) { string result = source; string::size_type pos = 0; while (pos = result.find(find, pos), pos != string::npos) { result.replace(pos, find.length(), alt); pos += alt.length(); } return result; } template <typename T> bool VECTOR_EXISTS(vector<T> vec, T data) { auto itr = std::find(vec.begin(), vec.end(), data); size_t index = distance(vec.begin(), itr); if (index != vec.size()) return true; else return false; } template <typename T> void VECTOR_REMOVE_VALUE_ALL(vector<T> &vec, T data) { vec.erase(remove(vec.begin(), vec.end(), data), vec.end()); } template <typename T> vector<T> VECTOR_REMOVE_VALUE_ALL_FAST(vector<T> vec, T data) { vector<T> vec2; for (auto &x : vec) if (x != data) vec2.push_back(x); return vec2; } bool REG_MATCH(string const &text, regex const &re) { bool result = regex_match(text, re); return result; } bool REG_MATCH(string const &text, smatch &match, regex const &re) { bool result = regex_match(text, match, re); return result; } smatch REG_SEARCH(string const &text, regex const &re) { smatch m; regex_search(text, m, re); return m; } vector<smatch> REG_ALL_SEARCH(string const &text, regex const &re) { vector<smatch> matchs; sregex_iterator iter(text.cbegin(), text.cend(), re); sregex_iterator end; for (; iter != end; iter++) matchs.push_back(*iter); return matchs; } string REG_REPLACE(string const &text, regex const &re, string const &replace) { string result = regex_replace(text, re, replace, regex_constants::format_first_only); return result; } string REG_ALL_REPLACE(string const &text, regex const &re, string const &replace) { string result = regex_replace(text, re, replace); return result; } template <typename T> vector<T> COMPRESS(vector<T> v) { sort(v.begin(), v.end()); v.erase(unique(v.begin(), v.end()), v.end()); return v; } template <typename T> pair<map<T, int>, map<int, T>> MAPPING(const vector<T> v) { map<T, int> zip; map<int, T> unzip; for (int i = 0; i < v.size(); i++) zip[v[i]] = i; for (int i = 0; i < v.size(); i++) unzip[i] = v[i]; return make_pair(zip, unzip); } template <typename T> vector<pair<T, int>> RUN_LENGTH(const vector<T> &v) { vector<pair<T, int>> ret; int len = v.size(); for (int i = 0, j = 0; i < len; i = j) { while (j < len && v[i] == v[j]) j++; ret.push_back(make_pair(v[i], j - i)); } return ret; } template <typename T, typename U, typename V, typename W> auto operator+(const std::pair<T, U> &l, const std::pair<V, W> &r) -> std::pair<decltype(l.first + r.first), decltype(l.second + r.second)> { return {l.first + r.first, l.second + r.second}; } template <typename T, typename U, typename V, typename W> auto operator-(const std::pair<T, U> &l, const std::pair<V, W> &r) -> std::pair<decltype(l.first - r.first), decltype(l.second - r.second)> { return {l.first - r.first, l.second - r.second}; } ostream &operator<<(ostream &dest, __int128_t value) { ostream::sentry s(dest); if (s) { __uint128_t tmp = value < 0 ? -value : value; char buffer[128]; char *d = std::end(buffer); do { --d; *d = "0123456789"[tmp % 10]; tmp /= 10; } while (tmp != 0); if (value < 0) { --d; *d = '-'; } int len = std::end(buffer) - d; if (dest.rdbuf()->sputn(d, len) != len) { dest.setstate(ios_base::badbit); } } return dest; } #define UPPER(s) transform((s).begin(), (s).end(), (s).begin(), ::toupper) #define LOWER(s) transform((s).begin(), (s).end(), (s).begin(), ::tolower) //四捨五入 nLen=小数点第n位にする //------------------------------------------ //切り上げ double ceil_n(double dIn, long long nLen) { double dOut; dOut = dIn * pow(10.0, nLen); dOut = (double)(long long)(dOut + 0.9); return dOut * pow(10.0, -nLen); } //切り捨て double floor_n(double dIn, long long nLen) { double dOut; dOut = dIn * pow(10.0, nLen); dOut = (double)(long long)(dOut); return dOut * pow(10.0, -nLen); } //四捨五入 double round_n(double dIn, long long nLen) { double dOut; dOut = dIn * pow(10.0, nLen); dOut = (double)(long long)(dOut + 0.5); return dOut * pow(10.0, -nLen); } // n桁目の数の取得 int take_a_n(LL num, int n) { string str = toString(num); return str[str.length() - n] - '0'; } int bitcount32(int bits) { bits = (bits & 0x55555555) + (bits >> 1 & 0x55555555); bits = (bits & 0x33333333) + (bits >> 2 & 0x33333333); bits = (bits & 0x0f0f0f0f) + (bits >> 4 & 0x0f0f0f0f); bits = (bits & 0x00ff00ff) + (bits >> 8 & 0x00ff00ff); return (bits & 0x0000ffff) + (bits >> 16 & 0x0000ffff); } //整数を2進数表記したときの1の個数を返す LL bitcount64(LL bits) { bits = (bits & 0x5555555555555555) + (bits >> 1 & 0x5555555555555555); bits = (bits & 0x3333333333333333) + (bits >> 2 & 0x3333333333333333); bits = (bits & 0x0f0f0f0f0f0f0f0f) + (bits >> 4 & 0x0f0f0f0f0f0f0f0f); bits = (bits & 0x00ff00ff00ff00ff) + (bits >> 8 & 0x00ff00ff00ff00ff); bits = (bits & 0x0000ffff0000ffff) + (bits >> 16 & 0x0000ffff0000ffff); return (bits & 0x00000000ffffffff) + (bits >> 32 & 0x00000000ffffffff); } // comparison //------------------------------------------ #define C_MAX(a, b) ((a) > (b) ? (a) : (b)) #define C_MIN(a, b) ((a) < (b) ? (a) : (b)) #define C_ABS(a, b) ((a) < (b) ? (b) - (a) : (a) - (b)) template <class T1, class T2> inline bool chmin(T1 &a, T2 b) { if (a > b) { a = b; return true; } return false; } template <class T1, class T2> inline bool chmax(T1 &a, T2 b) { if (a < b) { a = b; return true; } return false; } // container util //------------------------------------------ #define ALL(a) (a).begin(), (a).end() #define RALL(a) (a).rbegin(), (a).rend() #define SZ(a) int((a).size()) #define EACH(i, arr) \ for (typeof((arr).begin()) i = (arr).begin(); i != (arr).end(); ++i) #define EXIST(str, e) ((str).find(e) != (str).end()) #define COUNT(arr, v) count((arr).begin(), (arr).end(), v) #define SEARCH(v, w) search((v).begin(), (v).end(), (w).begin(), (w).end()) #define B_SEARCH(arr, v) binary_search((arr).begin(), (arr).end(), v) #define SORT(c) sort((c).begin(), (c).end()) #define RSORT(c) sort((c).rbegin(), (c).rend()) #define REVERSE(c) reverse((c).begin(), (c).end()) #define ROTATE_LEFT(arr, c) \ rotate((arr).begin(), (arr).begin() + (c), (arr).end()) #define ROTATE_RIGHT(arr, c) \ rotate((arr).rbegin(), (arr).rbegin() + (c), (arr).rend()) #define SUMI(arr) accumulate((arr).begin(), (arr).end(), 0) #define SUMD(arr) accumulate((arr).begin(), (arr).end(), 0.) #define SUMLL(arr) accumulate((arr).begin(), (arr).end(), 0LL) #define SUMS(arr) accumulate((arr).begin(), (arr).end(), string()) #define MULD(arr) \ accumulate((arr).begin(), (arr).end(), 1., multiplies<double>()) #define MULLL(arr) \ accumulate((arr).begin(), (arr).end(), 1LL, multiplies<long long>()) #define UB(arr, n) upper_bound((arr).begin(), (arr).end(), n) #define LB(arr, n) lower_bound((arr).begin(), (arr).end(), n) #define OF_ALL(arr, func) all_of((arr).begin(), (arr).end(), (func)) #define OF_NONE(arr, func) none_of((arr).begin(), (arr).end(), (func)) #define OF_ANY(arr, func) any_of((arr).begin(), (arr).end(), (func)) #define PB push_back #define MP make_pair #define ft first #define sd second // input output //------------------------------------------ #define GL(s) getline(cin, (s)) #define INIT() \ std::ios::sync_with_stdio(false); \ std::cin.tie(0); #define OUT(d) std::cout << (d) #define OUT_L(d) std::cout << (d) << endl #define FOUT(n, data) std::cout << std::fixed << std::setprecision(n) << (data) #define FOUT_L(n, data) \ std::cout << std::fixed << std::setprecision(n) << (data) << "\n" #define EL() printf("\n") #define SHOW_VECTOR(v) \ { \ std::cerr << #v << "\t:"; \ for (const auto &xxx : v) { \ std::cerr << xxx << " "; \ } \ std::cerr << "\n"; \ } #define SHOW_MAP(v) \ { \ std::cerr << #v << endl; \ for (const auto &xxx : v) { \ std::cerr << xxx.first << " " << xxx.second << "\n"; \ } \ } #define Yes() printf("Yes\n") #define No() printf("No\n") #define YES() printf("YES\n") #define NO() printf("NO\n") #define Yay() printf("Yay!\n") #define Nnn() printf(":(\n") template <typename T1, typename T2> istream &operator>>(istream &in, pair<T1, T2> &p) { in >> p.first >> p.second; return in; } template <typename T> istream &operator>>(istream &in, vector<T> &v) { for (auto &x : v) in >> x; return in; } istream &operator>>(istream &in, Lint &d) { string s; cin >> s; Lint tmp = 0; for (int i = 0; i < s.length(); i++) if ('0' <= s[i] && s[i] <= '9') tmp = 10 * tmp + s[i] - '0'; d = tmp; return in; } template <typename T1, typename T2> ostream &operator<<(ostream &out, const std::pair<T1, T2> &p) { out << "[" << p.first << ", " << p.second << "]" << "\n"; return out; } // repetition //------------------------------------------ #define FOR(i, a, b) for (int i = (a); i < (b); ++i) #define RFOR(i, a, b) for (int i = (b)-1; i >= (a); --i) #define REP(i, n) FOR(i, 0, n) #define RREP(i, n) for (int i = n - 1; i >= 0; i--) #define FORLL(i, a, b) for (LL i = LL(a); i < LL(b); ++i) #define RFORLL(i, a, b) for (LL i = LL(b) - 1; i >= LL(a); --i) #define REPLL(i, n) for (LL i = 0; i < LL(n); ++i) #define RREPLL(i, n) for (LL i = LL(n) - 1; i >= 0; --i) #define FOREACH(x, arr) for (auto &(x) : (arr)) #define FORITER(x, arr) for (auto(x) = (arr).begin(); (x) != (arr).end(); ++(x)) // constant //-------------------------------------------- const double EPS = 1e-10; const double PI = acos(-1.0); const int dx[] = {-1, 0, 1, 0}; const int dy[] = {0, 1, 0, -1}; // math //-------------------------------------------- // min <= aim <= max template <typename T> inline bool BETWEEN(const T aim, const T min, const T max) { if (min <= aim && aim <= max) { return true; } else { return false; } } template <typename T1, typename T2> inline bool IS_OUT(const T1 toY, const T1 toX, const T2 H, const T2 W) { return (toY < 0 || toY >= H || toX < 0 || toX >= W); } template <class T> inline T SQR(const T x) { return x * x; } template <class T1, class T2> inline T1 POW(const T1 x, const T2 y) { if (!y) return 1; else if ((y & 1) == 0) { return SQR(POW(x, y >> 1)); } else return POW(x, y ^ 1) * x; } template <typename T> constexpr T ABS(T x) { return x < 0 ? -x : x; } // partial_permutation nPr 順列 // first・・最初の数 // middle・・r(取り出す数) // last・・n(全体数) template <class Iter> bool next_partial_permutation(Iter first, Iter middle, Iter last) { reverse(middle, last); return next_permutation(first, last); } // combination nCr 組み合わせ // first1・・最初の数 // last1==first2・・r(取り出す数) // last2・・n(全体数) template <class Iter> bool next_combination(Iter first1, Iter last1, Iter first2, Iter last2) { if ((first1 == last1) || (first2 == last2)) { return false; } Iter m1 = last1; Iter m2 = last2; --m2; while (--m1 != first1 && !(*m1 < *m2)) { } bool result = (m1 == first1) && !(*first1 < *m2); if (!result) { while (first2 != m2 && !(*m1 < *first2)) { ++first2; } first1 = m1; std::iter_swap(first1, first2); ++first1; ++first2; } if ((first1 != last1) && (first2 != last2)) { m1 = last1; m2 = first2; while ((m1 != first1) && (m2 != last2)) { std::iter_swap(--m1, m2); ++m2; } std::reverse(first1, m1); std::reverse(first1, last1); std::reverse(m2, last2); std::reverse(first2, last2); } return !result; } // numeric_law //-------------------------------------------- template <typename T> constexpr bool ODD(T x) { return x % 2 != 0; } template <typename T> constexpr bool EVEN(T x) { return x % 2 == 0; } //最大公約数 template <class T> inline T GCD(const T x, const T y) { if (x < 0) return GCD(-x, y); if (y < 0) return GCD(x, -y); return (!y) ? x : GCD(y, x % y); } //最小公倍数 template <class T> inline T LCM(const T x, const T y) { if (x < 0) return LCM(-x, y); if (y < 0) return LCM(x, -y); return x * (y / GCD(x, y)); } // ax + by = gcd(a, b) // x,yが変数に格納される template <class T> inline T EXTGCD(const T a, const T b, T &x, T &y) { if (a < 0) { T d = EXTGCD(-a, b, x, y); x = -x; return d; } if (b < 0) { T d = EXTGCD(a, -b, x, y); y = -y; return d; } if (!b) { x = 1; y = 0; return a; } else { T d = EXTGCD(b, a % b, x, y); T t = x; x = y; y = t - (a / b) * y; return d; } } // mの世界でのaの逆元 // gce(a, m) = 1 template <class T> inline T INV_MOD(const T a, const T m) { T x, y; EXTGCD(a, m, x, y); return (x + m) % m; } template <class T> inline bool ISPRIME(const T x) { if (x <= 1) return false; for (T i = 2; i * i <= x; i++) if (x % i == 0) return false; return true; } template <class T> VB ERATOSTHENES(const T n) { VB arr(n + 1, true); arr[0] = arr[1] = false; for (T i = 2; i * i <= n; i++) { if (arr[i]) { for (T j = i * 2LL; j <= n; j += i) { arr[j] = false; } } } return arr; } // a <= x < b の素数を返す template <typename T> VB ERATOSTHENES(const T a, const T b) { VB small = ERATOSTHENES(b); VB prime(b - a, true); for (T i = 2; i * i <= b; i++) { if (small[i]) { for (T j = max(2LL, (a + i - 1) / i) * i; j < b; j += i) { prime[j - a] = false; } } } return prime; } // nの約数 template <typename T> vector<T> DIVISOR(T n) { vector<T> v; for (T i = 1; i * i <= n; ++i) { if (n % i == 0) { v.push_back(i); if (i != n / i) { v.push_back(n / i); } } } sort(v.begin(), v.end()); return v; } // nまでのすべての約数 template <typename T> vector<vector<T>> DIVISOR_ALL(T n) { vector<vector<T>> res(n + 1); for (T i = 1; i <= n; i++) { for (T j = i; j <= n; j += i) { res[j].push_back(i); } } return res; } template <typename T> vector<pair<T, T>> FACTORIZATION(T x) { vector<pair<T, LL>> ans; for (T i = 2; i * i <= x; i++) { if (x % i == 0) { T count = 0; while (x % i == 0) { count++; x /= i; } ans.push_back(MP(i, count)); } } if (x != 1) ans.push_back(MP(x, 1)); return ans; } LL POW_MOD(LL N, LL P, LL M) { LL ret = 1; while (P > 0) { if (P & 1LL) ret = (ret * N) % M; N = (N * N) % M; P >>= 1LL; } return ret; } template <typename T> inline T NCR(T n, T r) { if (r > n - r) r = n - r; T ans = 1LL; for (T i = 0; i < r; i++) { ans = ans * (n - i) / (i + 1); } return ans; } LL NCR_MOD(LL n, LL r, LL M) { if (r > n - r) return NCR_MOD(n, n - r, M); LL numerator = 1LL; //分子 LL denominator = 1LL; //分母 for (LL i = 0; i < r; i++) { numerator *= (n - i); numerator %= M; denominator *= (i + 1); denominator %= M; } return numerator * POW_MOD(denominator, M - 2, M) % M; } // confirmation //-------------------------------------------- // clear memory #define CLR(arr, d) memset((arr), (d), sizeof(arr)) // debug #define dump(x) cerr << #x << " = " << (x) << endl; #define debug(x) \ cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" \ << " " << endl; // 2019-04-14 //~~~~~~~~~~~~~~~~~~~~~_(^~^ 」 ∠)_~~~~~~~~~~~~~~~~~~~~~ constexpr LL MAX = 200010; int main() { LL N; cin >> N; VLL a(N); cin >> a; VLL b(MAX, 0); auto divisors = DIVISOR_ALL(MAX); VLL ans(N, 0); for (LL i = N - 1; i >= 0; i--) { LL d = i + 1; if ((a[i] + b[d]) % 2 == 0) { continue; } else { ans[i] = 1; REP(j, divisors[d].size()) { LL k = divisors[d][j]; b[k]++; } } } LL sum = SUMLL(ans); cout << sum << endl; for (int i = 0; i < N; i++) { if (ans[i] == 1) { cout << i + 1 << " "; } } return 0; }
[ "identifier.change", "call.arguments.change", "variable_access.subscript.index.change", "control_flow.branch.if.condition.change" ]
778,042
778,043
u259053514
cpp
p02972
#include <algorithm> #include <bitset> #include <cassert> #include <cmath> #include <complex> #include <functional> #include <iomanip> #include <iostream> #include <map> #include <queue> #include <set> #include <stack> #include <string> #include <time.h> #include <tuple> #include <utility> #include <vector> #define int long long #define endl '\n' #define INF 1000000000000000000 #define EPS 1e-10 #define PI 3.141592653589793238 #define all(a) a.begin(), a.end() #define rep(i, n) for (int i = 0; i < (n); i++) #define pb push_back #define double long double using namespace std; typedef long long ll; typedef pair<ll, ll> P; typedef pair<ll, P> PP; typedef complex<double> com; template <class T, class S> bool chmax(T &a, const S &b) { if (a < b) { a = b; return 1; } return 0; } template <class T, class S> bool chmin(T &a, const S &b) { if (a > b) { a = b; return 1; } return 0; } ll gcd(ll n, ll m) { return (m ? gcd(m, n % m) : n); } ll lcm(ll n, ll m) { return n / gcd(n, m) * m; } signed main() { cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); // modcalc(); int n; cin >> n; vector<int> a(n); rep(i, n) cin >> a[i]; vector<int> cnt(n); vector<int> ans; for (int i = n - 1; i >= 1; i--) { int s = 0; for (int j = 0; j < n; j += i) { if (cnt[j]) s ^= 1; } if (s != a[i - 1]) { ans.pb(i); cnt[i - 1] = 1; } } cout << ans.size() << endl; for (int i : ans) cout << i << ' '; if (ans.size() > 0) cout << endl; }
#include <algorithm> #include <bitset> #include <cassert> #include <cmath> #include <complex> #include <functional> #include <iomanip> #include <iostream> #include <map> #include <queue> #include <set> #include <stack> #include <string> #include <time.h> #include <tuple> #include <utility> #include <vector> #define int long long #define endl '\n' #define INF 1000000000000000000 #define EPS 1e-10 #define PI 3.141592653589793238 #define all(a) a.begin(), a.end() #define rep(i, n) for (int i = 0; i < (n); i++) #define pb push_back #define double long double using namespace std; typedef long long ll; typedef pair<ll, ll> P; typedef pair<ll, P> PP; typedef complex<double> com; template <class T, class S> bool chmax(T &a, const S &b) { if (a < b) { a = b; return 1; } return 0; } template <class T, class S> bool chmin(T &a, const S &b) { if (a > b) { a = b; return 1; } return 0; } ll gcd(ll n, ll m) { return (m ? gcd(m, n % m) : n); } ll lcm(ll n, ll m) { return n / gcd(n, m) * m; } signed main() { cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); // modcalc(); int n; cin >> n; vector<int> a(n); rep(i, n) cin >> a[i]; vector<int> cnt(n); vector<int> ans; for (int i = n; i >= 1; i--) { int s = 0; for (int j = i; j <= n; j += i) { if (cnt[j - 1]) s ^= 1; } if (s != a[i - 1]) { ans.pb(i); cnt[i - 1] = 1; } } cout << ans.size() << endl; for (int i : ans) cout << i << ' '; if (ans.size() > 0) cout << endl; }
[ "control_flow.loop.for.initializer.change", "expression.operation.binary.remove", "variable_declaration.value.change", "identifier.replace.add", "literal.replace.remove", "expression.operator.compare.change", "control_flow.loop.for.condition.change", "expression.off_by_one", "expression.operation.binary.change", "control_flow.branch.if.condition.change", "misc.off_by_one" ]
778,044
778,045
u179970156
cpp
p02972
#include <bits/stdc++.h> using namespace std; inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; } template <class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); } typedef vector<int> VI; typedef vector<VI> VVI; typedef vector<string> VS; typedef long long ll; typedef pair<int, int> P; typedef tuple<int, int, int> tpl; #define ALL(a) (a).begin(), (a).end() #define RALL(a) (a).rbegin(), (a).rend() #define SORT(c) sort((c).begin(), (c).end()) #define REVERSE(c) reverse((c).begin(), (c).end()) #define FOR(i, a, b) for (int i = (a); i < (b); ++i) #define REP(i, n) FOR(i, 0, n) #define RFOR(i, a, b) for (int i = (a)-1; i >= (b); --i) #define RREP(i, n) RFOR(i, n, 0) const double EPS = 1e-9; const double PI = acos(-1.0); const int INT_INF = 2147483647; const long long LL_INF = 1LL << 60; const long long MOD = 1000000007; #define CLR(a) memset((a), 0, sizeof(a)) #define dump(x) cerr << #x << " = " << (x) << endl; #define debug(x) \ cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" \ << " " << __FILE__ << endl; template <class T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; } template <class T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; } int main(void) { int N; cin >> N; VI a(N + 1, 0); REP(i, N) cin >> a[i + 1]; VI ans(N + 1, 0); RFOR(i, N + 1, 1) { int tmp = 0; for (int j = 2 * i; j <= N; j += i) { if (ans[j]) tmp++; } if (a[i + 1] != tmp % 2) ans[i] = 1; } int M = 0; REP(i, N) M += ans[i + 1]; cout << M << endl; REP(i, N) if (ans[i + 1]) cout << i + 1 << " "; cout << endl; return 0; }
#include <bits/stdc++.h> using namespace std; inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; } template <class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); } typedef vector<int> VI; typedef vector<VI> VVI; typedef vector<string> VS; typedef long long ll; typedef pair<int, int> P; typedef tuple<int, int, int> tpl; #define ALL(a) (a).begin(), (a).end() #define RALL(a) (a).rbegin(), (a).rend() #define SORT(c) sort((c).begin(), (c).end()) #define REVERSE(c) reverse((c).begin(), (c).end()) #define FOR(i, a, b) for (int i = (a); i < (b); ++i) #define REP(i, n) FOR(i, 0, n) #define RFOR(i, a, b) for (int i = (a)-1; i >= (b); --i) #define RREP(i, n) RFOR(i, n, 0) const double EPS = 1e-9; const double PI = acos(-1.0); const int INT_INF = 2147483647; const long long LL_INF = 1LL << 60; const long long MOD = 1000000007; #define CLR(a) memset((a), 0, sizeof(a)) #define dump(x) cerr << #x << " = " << (x) << endl; #define debug(x) \ cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" \ << " " << __FILE__ << endl; template <class T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; } template <class T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; } int main(void) { int N; cin >> N; VI a(N + 1, 0); REP(i, N) cin >> a[i + 1]; VI ans(N + 1, 0); RFOR(i, N + 1, 1) { int tmp = 0; for (int j = 2 * i; j <= N; j += i) { if (ans[j]) tmp++; } if (a[i] != tmp % 2) ans[i] = 1; } int M = 0; REP(i, N) M += ans[i + 1]; cout << M << endl; REP(i, N) if (ans[i + 1]) cout << i + 1 << " "; cout << endl; return 0; }
[ "expression.operation.binary.remove" ]
778,046
778,047
u934272719
cpp
p02972
#include <bits/stdc++.h> using namespace std; inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; } template <class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); } typedef vector<int> VI; typedef vector<VI> VVI; typedef vector<string> VS; typedef long long ll; typedef pair<int, int> P; typedef tuple<int, int, int> tpl; #define ALL(a) (a).begin(), (a).end() #define RALL(a) (a).rbegin(), (a).rend() #define SORT(c) sort((c).begin(), (c).end()) #define REVERSE(c) reverse((c).begin(), (c).end()) #define FOR(i, a, b) for (int i = (a); i < (b); ++i) #define REP(i, n) FOR(i, 0, n) #define RFOR(i, a, b) for (int i = (a)-1; i >= (b); --i) #define RREP(i, n) RFOR(i, n, 0) const double EPS = 1e-9; const double PI = acos(-1.0); const int INT_INF = 2147483647; const long long LL_INF = 1LL << 60; const long long MOD = 1000000007; #define CLR(a) memset((a), 0, sizeof(a)) #define dump(x) cerr << #x << " = " << (x) << endl; #define debug(x) \ cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" \ << " " << __FILE__ << endl; template <class T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; } template <class T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; } int main(void) { int N; cin >> N; VI a(N + 1, 0); REP(i, N) cin >> a[i + 1]; VI ans(N + 1, 0); RFOR(i, N + 1, 1) { int tmp = 0; for (int j = 2 * i; j < N; j += i) { if (ans[j]) tmp++; } if (a[i + 1] != tmp % 2) ans[i + 1] = 1; } int M = 0; REP(i, N) M += ans[i + 1]; cout << M << endl; REP(i, N) if (ans[i + 1]) cout << i + 1 << " "; cout << endl; return 0; }
#include <bits/stdc++.h> using namespace std; inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; } template <class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); } typedef vector<int> VI; typedef vector<VI> VVI; typedef vector<string> VS; typedef long long ll; typedef pair<int, int> P; typedef tuple<int, int, int> tpl; #define ALL(a) (a).begin(), (a).end() #define RALL(a) (a).rbegin(), (a).rend() #define SORT(c) sort((c).begin(), (c).end()) #define REVERSE(c) reverse((c).begin(), (c).end()) #define FOR(i, a, b) for (int i = (a); i < (b); ++i) #define REP(i, n) FOR(i, 0, n) #define RFOR(i, a, b) for (int i = (a)-1; i >= (b); --i) #define RREP(i, n) RFOR(i, n, 0) const double EPS = 1e-9; const double PI = acos(-1.0); const int INT_INF = 2147483647; const long long LL_INF = 1LL << 60; const long long MOD = 1000000007; #define CLR(a) memset((a), 0, sizeof(a)) #define dump(x) cerr << #x << " = " << (x) << endl; #define debug(x) \ cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" \ << " " << __FILE__ << endl; template <class T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; } template <class T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; } int main(void) { int N; cin >> N; VI a(N + 1, 0); REP(i, N) cin >> a[i + 1]; VI ans(N + 1, 0); RFOR(i, N + 1, 1) { int tmp = 0; for (int j = 2 * i; j <= N; j += i) { if (ans[j]) tmp++; } if (a[i] != tmp % 2) ans[i] = 1; } int M = 0; REP(i, N) M += ans[i + 1]; cout << M << endl; REP(i, N) if (ans[i + 1]) cout << i + 1 << " "; cout << endl; return 0; }
[ "expression.operator.compare.change", "control_flow.loop.for.condition.change", "expression.off_by_one", "expression.operation.binary.change", "expression.operation.binary.remove" ]
778,048
778,047
u934272719
cpp
p02972
#include <bits/stdc++.h> using namespace std; inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; } template <class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); } typedef vector<int> VI; typedef vector<VI> VVI; typedef vector<string> VS; typedef long long ll; typedef pair<int, int> P; typedef tuple<int, int, int> tpl; #define ALL(a) (a).begin(), (a).end() #define RALL(a) (a).rbegin(), (a).rend() #define SORT(c) sort((c).begin(), (c).end()) #define REVERSE(c) reverse((c).begin(), (c).end()) #define FOR(i, a, b) for (int i = (a); i < (b); ++i) #define REP(i, n) FOR(i, 0, n) #define RFOR(i, a, b) for (int i = (a)-1; i >= (b); --i) #define RREP(i, n) RFOR(i, n, 0) const double EPS = 1e-9; const double PI = acos(-1.0); const int INT_INF = 2147483647; const long long LL_INF = 1LL << 60; const long long MOD = 1000000007; #define CLR(a) memset((a), 0, sizeof(a)) #define dump(x) cerr << #x << " = " << (x) << endl; #define debug(x) \ cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" \ << " " << __FILE__ << endl; template <class T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; } template <class T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; } int main(void) { int N; cin >> N; VI a(N + 1, 0); REP(i, N) cin >> a[i + 1]; VI ans(N + 1, 0); RFOR(i, N + 1, 1) { int tmp = 0; for (int j = 2 * i; j < N; j += i) { if (ans[j]) tmp++; } if (a[i] != tmp % 2) ans[i] = 1; } int M = 0; REP(i, N) M += ans[i + 1]; cout << M << endl; REP(i, N) if (ans[i + 1]) cout << i + 1 << " "; cout << endl; return 0; }
#include <bits/stdc++.h> using namespace std; inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; } template <class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); } typedef vector<int> VI; typedef vector<VI> VVI; typedef vector<string> VS; typedef long long ll; typedef pair<int, int> P; typedef tuple<int, int, int> tpl; #define ALL(a) (a).begin(), (a).end() #define RALL(a) (a).rbegin(), (a).rend() #define SORT(c) sort((c).begin(), (c).end()) #define REVERSE(c) reverse((c).begin(), (c).end()) #define FOR(i, a, b) for (int i = (a); i < (b); ++i) #define REP(i, n) FOR(i, 0, n) #define RFOR(i, a, b) for (int i = (a)-1; i >= (b); --i) #define RREP(i, n) RFOR(i, n, 0) const double EPS = 1e-9; const double PI = acos(-1.0); const int INT_INF = 2147483647; const long long LL_INF = 1LL << 60; const long long MOD = 1000000007; #define CLR(a) memset((a), 0, sizeof(a)) #define dump(x) cerr << #x << " = " << (x) << endl; #define debug(x) \ cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" \ << " " << __FILE__ << endl; template <class T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; } template <class T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; } int main(void) { int N; cin >> N; VI a(N + 1, 0); REP(i, N) cin >> a[i + 1]; VI ans(N + 1, 0); RFOR(i, N + 1, 1) { int tmp = 0; for (int j = 2 * i; j <= N; j += i) { if (ans[j]) tmp++; } if (a[i] != tmp % 2) ans[i] = 1; } int M = 0; REP(i, N) M += ans[i + 1]; cout << M << endl; REP(i, N) if (ans[i + 1]) cout << i + 1 << " "; cout << endl; return 0; }
[ "expression.operator.compare.change", "control_flow.loop.for.condition.change", "expression.off_by_one", "expression.operation.binary.change" ]
778,049
778,047
u934272719
cpp
p02972
#include <bits/stdc++.h> using namespace std; inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; } template <class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); } typedef vector<int> VI; typedef vector<VI> VVI; typedef vector<string> VS; typedef long long ll; typedef pair<int, int> P; typedef tuple<int, int, int> tpl; #define ALL(a) (a).begin(), (a).end() #define RALL(a) (a).rbegin(), (a).rend() #define SORT(c) sort((c).begin(), (c).end()) #define REVERSE(c) reverse((c).begin(), (c).end()) #define FOR(i, a, b) for (int i = (a); i < (b); ++i) #define REP(i, n) FOR(i, 0, n) #define RFOR(i, a, b) for (int i = (a)-1; i >= (b); --i) #define RREP(i, n) RFOR(i, n, 0) const double EPS = 1e-9; const double PI = acos(-1.0); const int INT_INF = 2147483647; const long long LL_INF = 1LL << 60; const long long MOD = 1000000007; #define CLR(a) memset((a), 0, sizeof(a)) #define dump(x) cerr << #x << " = " << (x) << endl; #define debug(x) \ cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" \ << " " << __FILE__ << endl; template <class T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; } template <class T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; } int main(void) { int N; cin >> N; VI a(N + 1, 0); REP(i, N) cin >> a[i + 1]; VI ans(N + 1, 0); RFOR(i, N + 1, 1) { int tmp = 0; for (int j = 2 * i; j < N; j++) { if (ans[j]) tmp++; } if (a[i] % 2 != tmp % 2) ans[i] = 1; } int M = 0; REP(i, N) M += ans[i + 1]; cout << M << endl; REP(i, N) if (ans[i + 1]) cout << i + 1 << " "; cout << endl; return 0; }
#include <bits/stdc++.h> using namespace std; inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; } template <class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); } typedef vector<int> VI; typedef vector<VI> VVI; typedef vector<string> VS; typedef long long ll; typedef pair<int, int> P; typedef tuple<int, int, int> tpl; #define ALL(a) (a).begin(), (a).end() #define RALL(a) (a).rbegin(), (a).rend() #define SORT(c) sort((c).begin(), (c).end()) #define REVERSE(c) reverse((c).begin(), (c).end()) #define FOR(i, a, b) for (int i = (a); i < (b); ++i) #define REP(i, n) FOR(i, 0, n) #define RFOR(i, a, b) for (int i = (a)-1; i >= (b); --i) #define RREP(i, n) RFOR(i, n, 0) const double EPS = 1e-9; const double PI = acos(-1.0); const int INT_INF = 2147483647; const long long LL_INF = 1LL << 60; const long long MOD = 1000000007; #define CLR(a) memset((a), 0, sizeof(a)) #define dump(x) cerr << #x << " = " << (x) << endl; #define debug(x) \ cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" \ << " " << __FILE__ << endl; template <class T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; } template <class T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; } int main(void) { int N; cin >> N; VI a(N + 1, 0); REP(i, N) cin >> a[i + 1]; VI ans(N + 1, 0); RFOR(i, N + 1, 1) { int tmp = 0; for (int j = 2 * i; j <= N; j += i) { if (ans[j]) tmp++; } if (a[i] != tmp % 2) ans[i] = 1; } int M = 0; REP(i, N) M += ans[i + 1]; cout << M << endl; REP(i, N) if (ans[i + 1]) cout << i + 1 << " "; cout << endl; return 0; }
[ "expression.operator.compare.change", "control_flow.loop.for.condition.change", "expression.off_by_one", "expression.operation.binary.change", "expression.operation.binary.remove" ]
778,050
778,047
u934272719
cpp
p02972
#define _USE_MATH_DEFINES #include <algorithm> #include <cfloat> #include <climits> #include <cmath> #include <cstring> #include <functional> #include <iomanip> #include <iostream> #include <list> #include <map> #include <queue> #include <stack> #include <stdio.h> #include <string.h> #include <string> #include <tuple> #include <vector> using ll = long long; // LLONG_MAX #define int long long #define CONTAINS(v, n) (find((v).begin(), (v).end(), (n)) != (v).end()) #define SORT(v) sort((v).begin(), (v).end()) #define RSORT(v) sort((v).rbegin(), (v).rend()) #define ARY_SORT(a, size) sort((a), (a) + (size)) #define REMOVE(v, a) (v.erase(remove((v).begin(), (v).end(), (a)), (v).end())) #define REVERSE(v) (reverse((v).begin(), (v).end())) #define LOWER_BOUND(v, a) (lower_bound((v).begin(), (v).end(), (a))) #define UPPER_BOUND(v, a) (upper_bound((v).begin(), (v).end(), (a))) #define REP(i, n) for (int(i) = 0; (i) < (n); (i)++) #define CONTAINS_MAP(m, a) (m).find((a)) != m.end() using namespace std; int N; int A[200010]; int B[200010]; signed main() { cin >> N; REP(i, N) cin >> A[i + 1]; for (int i = N; i >= 1; i--) { int s = 0; int c = i * 2; while (c <= N) { s ^= B[c]; c *= 2; } B[i] = (A[i] ^ s); } int cnt = 0; for (int i = 1; i <= N; i++) { if (B[i]) { cnt++; } } cout << cnt << endl; for (int i = 1; i <= N; i++) { if (B[i]) { cout << i << " "; } } cout << endl; }
#define _USE_MATH_DEFINES #include <algorithm> #include <cfloat> #include <climits> #include <cmath> #include <cstring> #include <functional> #include <iomanip> #include <iostream> #include <list> #include <map> #include <queue> #include <stack> #include <stdio.h> #include <string.h> #include <string> #include <tuple> #include <vector> using ll = long long; // LLONG_MAX #define int long long #define CONTAINS(v, n) (find((v).begin(), (v).end(), (n)) != (v).end()) #define SORT(v) sort((v).begin(), (v).end()) #define RSORT(v) sort((v).rbegin(), (v).rend()) #define ARY_SORT(a, size) sort((a), (a) + (size)) #define REMOVE(v, a) (v.erase(remove((v).begin(), (v).end(), (a)), (v).end())) #define REVERSE(v) (reverse((v).begin(), (v).end())) #define LOWER_BOUND(v, a) (lower_bound((v).begin(), (v).end(), (a))) #define UPPER_BOUND(v, a) (upper_bound((v).begin(), (v).end(), (a))) #define REP(i, n) for (int(i) = 0; (i) < (n); (i)++) #define CONTAINS_MAP(m, a) (m).find((a)) != m.end() using namespace std; int N; int A[200010]; int B[200010]; signed main() { cin >> N; REP(i, N) cin >> A[i + 1]; for (int i = N; i >= 1; i--) { int s = 0; int c = i * 2; while (c <= N) { s ^= B[c]; c += i; } B[i] = (A[i] ^ s); } int cnt = 0; for (int i = 1; i <= N; i++) { if (B[i]) { cnt++; } } cout << cnt << endl; for (int i = 1; i <= N; i++) { if (B[i]) { cout << i << " "; } } cout << endl; }
[ "assignment.change" ]
778,053
778,054
u624800360
cpp
p02972
#include <algorithm> #include <iostream> #include <vector> using namespace std; typedef long long ll; template <class T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; } template <class T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; } vector<ll> calc_factors(const ll n) { vector<ll> factors; factors.push_back(1); // factors.push_back(n); for (ll i = 2; i * i <= n; i++) { if (n % i == 0) { if (i * i != n) { factors.push_back(i); factors.push_back(n / i); } else { factors.push_back(i); } } } return factors; } void disp(const vector<int> &xs) { for (int i = 0; i < (int)xs.size(); i++) { cout << xs[i] << " "; } cout << endl; } void solve(const int N, const vector<ll> &a, vector<ll> &counter, vector<ll> &ans) { for (ll n = N; n > 0; n--) { // disp(counter); if (a[n] == 0) { if (counter[n] % 2 == 0) { ans[n] = 0; } else { ans[n] = 1; vector<ll> factors = calc_factors(n); for (int i = 0; i < (int)factors.size(); i++) { counter[factors[i]]++; } } } else { if (counter[n] % 2 == 0) { ans[n] = 1; vector<ll> factors = calc_factors(n); for (int i = 0; i < (int)factors.size(); i++) { counter[factors[i]]++; } } else { ans[n] = 0; } } } } int main(void) { int N; cin >> N; vector<ll> a(N + 1); for (int i = 1; i <= N; i++) { cin >> a[i]; } vector<ll> counter(N + 1, 0); vector<ll> ans(N + 1, -1); ans[0] = 0; solve(N, a, counter, ans); int num = 0; for (int i = 0; i < N; i++) { if (ans[i] == 1) { num++; } } cout << num << endl; if (num > 0) { for (int i = 1; i <= N; i++) { if (ans[i] == 1) { cout << i << " "; } } cout << endl; } return 0; }
#include <algorithm> #include <iostream> #include <vector> using namespace std; typedef long long ll; template <class T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; } template <class T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; } vector<ll> calc_factors(const ll n) { vector<ll> factors; factors.push_back(1); // factors.push_back(n); for (ll i = 2; i * i <= n; i++) { if (n % i == 0) { if (i * i != n) { factors.push_back(i); factors.push_back(n / i); } else { factors.push_back(i); } } } return factors; } void disp(const vector<int> &xs) { for (int i = 0; i < (int)xs.size(); i++) { cout << xs[i] << " "; } cout << endl; } void solve(const int N, const vector<ll> &a, vector<ll> &counter, vector<ll> &ans) { for (ll n = N; n > 0; n--) { // disp(counter); if (a[n] == 0) { if (counter[n] % 2 == 0) { ans[n] = 0; } else { ans[n] = 1; vector<ll> factors = calc_factors(n); for (int i = 0; i < (int)factors.size(); i++) { counter[factors[i]]++; } } } else { if (counter[n] % 2 == 0) { ans[n] = 1; vector<ll> factors = calc_factors(n); for (int i = 0; i < (int)factors.size(); i++) { counter[factors[i]]++; } } else { ans[n] = 0; } } } } int main(void) { int N; cin >> N; vector<ll> a(N + 1); for (int i = 1; i <= N; i++) { cin >> a[i]; } vector<ll> counter(N + 1, 0); vector<ll> ans(N + 1, -1); ans[0] = 0; solve(N, a, counter, ans); int num = 0; for (int i = 1; i <= N; i++) { if (ans[i] == 1) { num++; } } cout << num << endl; if (num > 0) { for (int i = 1; i <= N; i++) { if (ans[i] == 1) { cout << i << " "; } } cout << endl; } return 0; }
[ "literal.number.change", "variable_declaration.value.change", "control_flow.loop.for.initializer.change", "expression.off_by_one", "expression.operator.compare.change", "control_flow.loop.for.condition.change", "expression.operation.binary.change" ]
778,057
778,058
u644332191
cpp
p02972
// // Created by Hideaki Imamura on 2020-03-18. // #include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<ll, ll> l_l; typedef pair<int, int> i_i; template <class T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; } template <class T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; } #define EPS (1e-7) #define INF (1e9) #define PI (acos(-1)) // const ll mod = 1000000007; int N; vector<int> a; int main() { cin >> N; a.assign(N, 0); for (int i = 0; i < N; ++i) cin >> a[i]; vector<int> b(N, 0); for (int i = N - 1; i >= 0; --i) { int counter = 2; int sum = 0; while ((i + 1) * counter < N) { sum += b[(i + 1) * counter - 1]; counter++; } b[i] = sum % 2 == a[i] ? 0 : 1; } int M = accumulate(b.begin(), b.end(), 0); cout << M << endl; for (int i = 0; i < N; ++i) { if (b[i]) cout << i + 1 << " "; } if (M) cout << endl; return 0; }
// // Created by Hideaki Imamura on 2020-03-18. // #include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<ll, ll> l_l; typedef pair<int, int> i_i; template <class T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; } template <class T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; } #define EPS (1e-7) #define INF (1e9) #define PI (acos(-1)) // const ll mod = 1000000007; int N; vector<int> a; int main() { cin >> N; a.assign(N, 0); for (int i = 0; i < N; ++i) cin >> a[i]; vector<int> b(N, 0); for (int i = N - 1; i >= 0; --i) { int counter = 2; int sum = 0; while ((i + 1) * counter - 1 < N) { sum += b[(i + 1) * counter - 1]; counter++; } b[i] = sum % 2 == a[i] ? 0 : 1; } int M = accumulate(b.begin(), b.end(), 0); cout << M << endl; for (int i = 0; i < N; ++i) { if (b[i]) cout << i + 1 << " "; } if (M) cout << endl; return 0; }
[ "control_flow.loop.condition.change", "control_flow.loop.for.condition.change", "misc.off_by_one" ]
778,061
778,062
u477855214
cpp
p02972
#include <algorithm> #include <climits> #include <cmath> #include <cstdio> #include <cstdlib> #include <cstring> #include <fstream> #include <iomanip> #include <iostream> #include <map> #include <queue> #include <set> #include <stack> #include <string> #include <vector> #define MOD (1000000007) using namespace std; typedef long long int Int; constexpr Int TEN(int n) { return n == 0 ? 1 : 10 * TEN(n - 1); } const int max_n = 200000 + 10; int N; int A[2 * max_n]; int B[2 * max_n]; int main(void) { cin >> N; int M = 0; for (int i = 1; i <= N; i++) { cin >> A[i]; } for (int i = N; i >= 1; i--) { int sum = 0; for (int j = 1; j * i <= N; j++) { sum += B[i * j]; } if (sum % 2 != A[i]) { M++; B[i] = 1; } } vector<int> C; for (int i = 1; i <= N; i++) { if (B[i] == 1) C.push_back(1); } cout << M << endl; if (M > 0) { for (auto d : C) { cout << d << " "; } } return 0; }
#include <algorithm> #include <climits> #include <cmath> #include <cstdio> #include <cstdlib> #include <cstring> #include <fstream> #include <iomanip> #include <iostream> #include <map> #include <queue> #include <set> #include <stack> #include <string> #include <vector> #define MOD (1000000007) using namespace std; typedef long long int Int; constexpr Int TEN(int n) { return n == 0 ? 1 : 10 * TEN(n - 1); } const int max_n = 200000 + 10; int N; int A[2 * max_n]; int B[2 * max_n]; int main(void) { cin >> N; int M = 0; for (int i = 1; i <= N; i++) { cin >> A[i]; } for (int i = N; i >= 1; i--) { int sum = 0; for (int j = 1; j * i <= N; j++) { sum += B[i * j]; } if (sum % 2 != A[i]) { M++; B[i] = 1; } } vector<int> C; for (int i = 1; i <= N; i++) { if (B[i] == 1) C.push_back(i); } cout << M << endl; if (M > 0) { for (auto d : C) { cout << d << " "; } } return 0; }
[ "identifier.replace.add", "literal.replace.remove", "call.arguments.change" ]
778,064
778,065
u498141549
cpp
p02972
#include <algorithm> #include <bitset> #include <cassert> #include <cctype> #include <cfloat> #include <climits> #include <cmath> #include <cstdio> #include <iomanip> #include <iostream> #include <list> #include <map> #include <queue> #include <set> #include <stack> #include <string> #include <unordered_set> #include <vector> using namespace std; typedef long double ld; typedef long long int ll; typedef unsigned long long int ull; typedef pair<int, int> pii; typedef vector<int> vi; typedef vector<char> vc; typedef vector<bool> vb; typedef vector<double> vd; typedef vector<string> vs; typedef vector<ll> vll; typedef vector<pair<int, int>> vpii; typedef vector<vector<int>> vvi; typedef vector<vector<char>> vvc; typedef vector<vector<string>> vvs; typedef vector<vector<ll>> vvll; #define rep(i, n) for (int i = 0; i < (n); ++i) #define rrep(i, n) for (int i = 1; i <= (n); ++i) #define irep(it, stl) for (auto it = stl.begin(); it != stl.end(); it++) #define drep(i, n) for (int i = (n)-1; i >= 0; --i) #define fin(ans) cout << (ans) << endl #define mp(p, q) make_pair(p, q) #define pb(n) push_back(n) #define all(a) a.begin(), a.end() #define rall(a) a.rbegin(), a.rend() #define Sort(a) sort(a.begin(), a.end()) #define Rort(a) sort(a.rbegin(), a.rend()) #define MATHPI acos(-1) int dx8[8] = {1, 0, -1, 0, 1, -1, -1, 1}; int dy8[8] = {0, 1, 0, -1, 1, 1, -1, -1}; int dx4[4] = {1, 0, -1, 0}; int dy4[4] = {0, 1, 0, -1}; template <class T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return 1; } return 0; } template <class T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return 1; } return 0; } template <typename A, size_t N, typename T> void Fill(A (&array)[N], const T &val) { fill((T *)array, (T *)(array + N), val); } struct io { io() { ios::sync_with_stdio(false); cin.tie(0); } }; const int INF = INT_MAX; const ll LLINF = 1LL << 60; const ll MOD = 1000000007; const double EPS = 1e-9; template <typename T> inline string toString(const T &a) { ostringstream oss; oss << a; return oss.str(); }; int main() { int N; vi a(N + 1); rrep(i, N) cin >> a[i]; vi ans; vi b(N + 1, 0); for (int i = N; i >= 1; i--) { int sum = 0; for (int j = i; j <= N; j += i) { sum += b[j]; //倍数の和 } if (sum % 2 != a[i]) { //規定に合わなかったらボールを入れてあげる b[i] = 1; ans.push_back(i); } } cout << ans.size() << endl; rep(i, ans.size()) { cout << ans[i] << " "; } }
#include <algorithm> #include <bitset> #include <cassert> #include <cctype> #include <cfloat> #include <climits> #include <cmath> #include <cstdio> #include <iomanip> #include <iostream> #include <list> #include <map> #include <queue> #include <set> #include <stack> #include <string> #include <unordered_set> #include <vector> using namespace std; typedef long double ld; typedef long long int ll; typedef unsigned long long int ull; typedef pair<int, int> pii; typedef vector<int> vi; typedef vector<char> vc; typedef vector<bool> vb; typedef vector<double> vd; typedef vector<string> vs; typedef vector<ll> vll; typedef vector<pair<int, int>> vpii; typedef vector<vector<int>> vvi; typedef vector<vector<char>> vvc; typedef vector<vector<string>> vvs; typedef vector<vector<ll>> vvll; #define rep(i, n) for (int i = 0; i < (n); ++i) #define rrep(i, n) for (int i = 1; i <= (n); ++i) #define irep(it, stl) for (auto it = stl.begin(); it != stl.end(); it++) #define drep(i, n) for (int i = (n)-1; i >= 0; --i) #define fin(ans) cout << (ans) << endl #define mp(p, q) make_pair(p, q) #define pb(n) push_back(n) #define all(a) a.begin(), a.end() #define rall(a) a.rbegin(), a.rend() #define Sort(a) sort(a.begin(), a.end()) #define Rort(a) sort(a.rbegin(), a.rend()) #define MATHPI acos(-1) int dx8[8] = {1, 0, -1, 0, 1, -1, -1, 1}; int dy8[8] = {0, 1, 0, -1, 1, 1, -1, -1}; int dx4[4] = {1, 0, -1, 0}; int dy4[4] = {0, 1, 0, -1}; template <class T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return 1; } return 0; } template <class T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return 1; } return 0; } template <typename A, size_t N, typename T> void Fill(A (&array)[N], const T &val) { fill((T *)array, (T *)(array + N), val); } struct io { io() { ios::sync_with_stdio(false); cin.tie(0); } }; const int INF = INT_MAX; const ll LLINF = 1LL << 60; const ll MOD = 1000000007; const double EPS = 1e-9; template <typename T> inline string toString(const T &a) { ostringstream oss; oss << a; return oss.str(); }; int main() { int N; cin >> N; vi a(N + 1); rrep(i, N) cin >> a[i]; vi ans; vi b(N + 1, 0); for (int i = N; i >= 1; i--) { int sum = 0; for (int j = i; j <= N; j += i) { sum += b[j]; //倍数の和 } if (sum % 2 != a[i]) { //規定に合わなかったらボールを入れてあげる b[i] = 1; ans.push_back(i); } } cout << ans.size() << endl; rep(i, ans.size()) { cout << ans[i] << " "; } }
[]
778,066
778,067
u484274300
cpp
p02972
#define rep(i, n) for (ll i = 0; i < n; i++) #include "bits/stdc++.h" using namespace std; using ll = long long; using P = pair<int, int>; int main() { int n; cin >> n; vector<int> a(n + 1); vector<int> b(n + 1); rep(i, n) { cin >> a[i + 1]; } // floor(n)+1,…nまでは一意に定まる for (int i = n / 2 + 1; i < n; i++) { b[i] = a[i]; } for (int i = n / 2; i >= 1; i--) { int sum_b = 0; for (int j = 2 * i; j < n; j += i) { sum_b += b[j]; } sum_b %= 2; b[i] = (2 + a[i] - sum_b) % 2; } int m = 0; rep(i, n) { m += b[i + 1]; } cout << m << endl; rep(i, n) { if (b[i + 1] == 1) cout << i + 1 << " "; } return 0; }
#define rep(i, n) for (ll i = 0; i < n; i++) #include "bits/stdc++.h" using namespace std; using ll = long long; using P = pair<int, int>; int main() { int n; cin >> n; vector<int> a(n + 1); vector<int> b(n + 1); rep(i, n) { cin >> a[i + 1]; } // floor(n)+1,…nまでは一意に定まる for (int i = n / 2 + 1; i <= n; i++) { b[i] = a[i]; } for (int i = n / 2; i >= 1; i--) { int sum_b = 0; for (int j = 2 * i; j <= n; j += i) { sum_b += b[j]; } sum_b %= 2; b[i] = (2 + a[i] - sum_b) % 2; } int m = 0; rep(i, n) { m += b[i + 1]; } cout << m << endl; rep(i, n) { if (b[i + 1] == 1) cout << i + 1 << " "; } return 0; }
[ "expression.operator.compare.change", "control_flow.loop.for.condition.change", "expression.off_by_one", "expression.operation.binary.change" ]
778,072
778,073
u518206537
cpp
p02972
#include <algorithm> #include <cassert> #include <cmath> #include <cstdio> #include <cstdlib> #include <cstring> #include <functional> #include <iomanip> #include <iostream> #include <map> #include <numeric> #include <queue> #include <set> #include <string> #include <unordered_map> #include <unordered_set> #include <vector> using namespace std; typedef long long ll; typedef pair<ll, ll> P; typedef pair<ll, ll> PL; const ll mod = 1000000007; // const ll mod = 998244353; const ll MOD = 1000000007; const ll INF = 1LL << 60; #define PI (acos(-1)) #define ALL(c) (c).begin(), (c).end() #define en '\n' #define endl '\n' template <typename T> istream &operator>>(istream &is, vector<T> &vec) { for (auto &v : vec) is >> v; return is; } template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec) { os << "["; for (auto v : vec) os << v << ","; os << "]"; return os; } template <typename T> ostream &operator<<(ostream &os, const deque<T> &vec) { os << "deq["; for (auto v : vec) os << v << ","; os << "]"; return os; } template <typename T> ostream &operator<<(ostream &os, const set<T> &vec) { os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; } template <typename T> ostream &operator<<(ostream &os, const multiset<T> &vec) { os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; } template <typename T1, typename T2> ostream &operator<<(ostream &os, const pair<T1, T2> &pa) { os << "(" << pa.first << "," << pa.second << ")"; return os; } template <typename TK, typename TV> ostream &operator<<(ostream &os, const map<TK, TV> &mp) { os << "{"; for (auto v : mp) os << v.first << "=>" << v.second << ","; os << "}"; return os; } #define dbg(x) \ cerr << #x << " = " << (x) << " (L" << __LINE__ << ") " << __FILE__ << endl; // template <typename A, size_t N, typename T> template <typename T> inline string toString(const T &a) { ostringstream oss; oss << a; return oss.str(); }; template <int mod> struct ModInt { int x; ModInt() : x(0) {} ModInt(int64_t y) : x(y >= 0 ? y % mod : (mod - (-y) % mod) % mod) {} ModInt &operator+=(const ModInt &p) { if ((x += p.x) >= mod) x -= mod; return *this; } ModInt &operator-=(const ModInt &p) { if ((x += mod - p.x) >= mod) x -= mod; return *this; } ModInt &operator*=(const ModInt &p) { x = (int)(1LL * x * p.x % mod); return *this; } ModInt &operator/=(const ModInt &p) { *this *= p.inverse(); return *this; } ModInt operator-() const { return ModInt(-x); } ModInt operator+(const ModInt &p) const { return ModInt(*this) += p; } ModInt operator-(const ModInt &p) const { return ModInt(*this) -= p; } ModInt operator*(const ModInt &p) const { return ModInt(*this) *= p; } ModInt operator/(const ModInt &p) const { return ModInt(*this) /= p; } bool operator==(const ModInt &p) const { return x == p.x; } bool operator!=(const ModInt &p) const { return x != p.x; } ModInt inverse() const { int a = x, b = mod, u = 1, v = 0, t; while (b > 0) { t = a / b; swap(a -= t * b, b); swap(u -= t * v, v); } return ModInt(u); } ModInt pow(int64_t n) const { ModInt ret(1), mul(x); while (n > 0) { if (n & 1) ret *= mul; mul *= mul; n >>= 1; } return ret; } friend ostream &operator<<(ostream &os, const ModInt &p) { return os << p.x; } friend istream &operator>>(istream &is, ModInt &a) { int64_t t; is >> t; a = ModInt<mod>(t); return (is); } static int get_mod() { return mod; } }; using modint = ModInt<mod>; template <typename T> struct Combination { vector<T> _fact, _rfact, _inv; Combination(int sz) : _fact(sz + 1), _rfact(sz + 1), _inv(sz + 1) { _fact[0] = _rfact[sz] = _inv[0] = 1; for (int i = 1; i <= sz; i++) _fact[i] = _fact[i - 1] * i; _rfact[sz] /= _fact[sz]; for (int i = sz - 1; i >= 0; i--) _rfact[i] = _rfact[i + 1] * (i + 1); for (int i = 1; i <= sz; i++) _inv[i] = _rfact[i] * _fact[i - 1]; } inline T fact(int k) const { return _fact[k]; } inline T rfact(int k) const { return _rfact[k]; } inline T inv(int k) const { return _inv[k]; } T P(int n, int r) const { if (r < 0 || n < r) return 0; return fact(n) * rfact(n - r); } T C(int p, int q) const { if (q < 0 || p < q) return 0; return fact(p) * rfact(q) * rfact(p - q); } T H(int n, int r) const { if (n < 0 || r < 0) return (0); return r == 0 ? 1 : C(n + r - 1, r); } T NC(int p, int q) const { modint ret = 1; for (int i = 1; i <= q; i += 1) { ret = ret * p / i; p--; } return ret; } }; ll lcm(ll a, ll b) { return a / __gcd(a, b) * b; } bool is_prime(ll x) { if (x == 1) { return false; } for (ll i = 2; i * i <= x; i++) { if (x % i == 0) return false; } return true; } map<ll, int> prime_factor(ll n) { map<ll, int> ret; for (ll i = 2; i * i <= n; i++) { while (n % i == 0) { ret[i]++; n /= i; } } if (n != 1) ret[n] = 1; return ret; } vector<ll> divisor(ll n) { vector<ll> ret; for (ll i = 1; i * i <= n; i++) { if (n % i == 0) { ret.push_back(i); if (i * i != n) ret.push_back(n / i); } } sort(begin(ret), end(ret)); return (ret); } long long modpow(long long a, long long n, long long mod) { long long res = 1; while (n > 0) { if (n & 1) res = res * a % mod; a = a * a % mod; n >>= 1; } return res; } long long modinv(long long a, long long mod) { return modpow(a, mod - 2, mod); } const ll MAX = 510000; ll fac[MAX], finv[MAX], inv[MAX]; void COMinit() { fac[0] = fac[1] = 1; finv[0] = finv[1] = 1; inv[1] = 1; for (ll i = 2; i < MAX; i++) { fac[i] = fac[i - 1] * i % MOD; inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD; finv[i] = finv[i - 1] * inv[i] % MOD; } } ll COM(ll n, ll k) { if (n < k) return 0; if (n < 0 || k < 0) return 0; return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD; } struct UnionFind { vector<int> par; UnionFind(int n) : par(n, -1) {} void init(int n) { par.assign(n, -1); } int root(int x) { if (par[x] < 0) return x; else return par[x] = root(par[x]); } bool issame(int x, int y) { return root(x) == root(y); } bool merge(int x, int y) { x = root(x); y = root(y); if (x == y) return false; if (par[x] > par[y]) swap(x, y); // merge technique par[x] += par[y]; par[y] = x; return true; } int size(int x) { return -par[root(x)]; } }; struct BIT { // 1-indexed!!! int n; vector<int> bit; BIT() { init(); } BIT(int n) : n(n) { init(); } void init() { bit.clear(); bit.resize(n + 1, 0); } int sum(int i) { int s = 0; while (i > 0) { s += bit[i]; i -= i & -i; } return s; } int sum(int x, int y) { return sum(y) - sum(x - 1); } void add(int i, int x) { while (i <= n) { bit[i] += x; i += i & -i; } } int lower_bound(int w) { if (w <= 0) return 0; int x = 0, r = 1; while (r < n) r <<= 1; for (int k = r; k > 0; k >>= 1) { if (x + k <= n && bit[x + k] < w) { w -= bit[x + k]; x += k; } } return x + 1; } }; struct LazySegmentTree { // private: ll n; vector<ll> node, lazy; // public: LazySegmentTree(vector<ll> v) { int sz = (int)v.size(); n = 1; while (n < sz) n *= 2; node.resize(2 * n - 1); lazy.resize(2 * n - 1, 0); for (int i = 0; i < sz; i++) node[i + n - 1] = v[i]; for (int i = n - 2; i >= 0; i--) node[i] = node[i * 2 + 1] + node[i * 2 + 2]; } void eval(int k, int l, int r) { if (lazy[k] != 0) { node[k] += lazy[k]; if (r - l > 1) { lazy[2 * k + 1] += lazy[k] / 2; lazy[2 * k + 2] += lazy[k] / 2; } lazy[k] = 0; } } void add(int a, int b, ll x, int k = 0, int l = 0, int r = -1) { if (r < 0) r = n; eval(k, l, r); if (b <= l || r <= a) return; if (a <= l && r <= b) { lazy[k] += (r - l) * x; eval(k, l, r); } else { add(a, b, x, 2 * k + 1, l, (l + r) / 2); add(a, b, x, 2 * k + 2, (l + r) / 2, r); node[k] = node[2 * k + 1] + node[2 * k + 2]; } } ll getsum(int a, int b, int k = 0, int l = 0, int r = -1) { if (r < 0) r = n; eval(k, l, r); if (b <= l || r <= a) return 0; if (a <= l && r <= b) return node[k]; ll vl = getsum(a, b, 2 * k + 1, l, (l + r) / 2); ll vr = getsum(a, b, 2 * k + 2, (l + r) / 2, r); return vl + vr; } }; ll digit_sum(ll v) { ll ret = 0; while (v) { ret += (v % 10); v /= 10; } return ret; } template <typename T> struct Kruskal { struct edge { ll from, to; T cost; ll used; edge() {} edge(ll from, ll to, T cost) : from(from), to(to), cost(cost), used(0) {} bool operator<(const edge &e) const { return cost < e.cost; } }; ll n; vector<ll> p, r; vector<edge> edges; Kruskal() {} Kruskal(ll n) : n(n) {} void init(ll n) { r.assign(n, 1); p.resize(n); iota(p.begin(), p.end(), 0); } ll find(ll x) { return (x == p[x] ? x : p[x] = find(p[x])); } bool same(ll x, ll y) { return find(x) == find(y); } void unite(ll x, ll y) { x = find(x); y = find(y); if (x == y) return; if (r[x] < r[y]) swap(x, y); r[x] += r[y]; p[y] = x; } void add_edge(ll u, ll v, T c) { edges.emplace_back(u, v, c); } T build() { sort(edges.begin(), edges.end()); init(n); T res = 0; for (auto &e : edges) { if (!same(e.from, e.to)) { res += e.cost; unite(e.from, e.to); e.used = 1; } } return res; } T build(ll k) { sort(edges.begin(), edges.end()); init(n); T res = 0; ll cnt = 0; for (auto &e : edges) { if (!same(e.from, e.to)) { res += e.cost; unite(e.from, e.to); e.used = 1; cnt++; } if (cnt == k) { break; } } return res; } }; int LIS(int a[], int n) { vector<int> A(n, 0x3f3f3f3f); for (int i = 0; i < n; i++) *lower_bound(A.begin(), A.end(), a[i]) = a[i]; return find(A.begin(), A.end(), 0x3f3f3f3f) - A.begin(); } // string maze[1010]; // //ll maze[100][100]; // ll grid_bfs(ll H, ll W, ll sx, ll sy, ll gx, ll gy) // { // //O(E) // int dx[4] = {1, 0, -1, 0}; // int dy[4] = {0, 1, 0, -1}; // vector<vector<ll>> dist(H, vector<ll>(W, -1)); // dist[sy][sx] = 0; // queue<PL> q; // q.push({sy, sx}); // while (!q.empty()) // { // ll x, y; // tie(y, x) = q.front(); // q.pop(); // if (y == gy && x == gx) // { // break; // } // for (int t = 0; t < 4; t++) // { // ll nx = x + dx[t], ny = y + dy[t]; // if (nx < 0 || ny < 0 || nx >= W || ny >= H || dist[ny][nx] != -1 // || maze[ny][nx] == '#') // { // continue; // } // dist[ny][nx] = dist[y][x] + 1; // q.push({ny, nx}); // } // } // return dist[gy][gx]; // } // no verify ll bfs(ll n, ll start, vector<vector<PL>> Edges) { vector<ll> dist(n + 1, -1); dist[start] = 0; queue<PL> q; q.push({start, 0}); while (!q.empty()) { ll node, cost; tie(cost, node) = q.front(); q.pop(); for (auto p : Edges[node]) { ll v = p.first, cost = p.second; if (dist[v] == -1) { dist[v] = dist[node] + cost; q.push({v, cost}); } } } } vector<vector<ll>> warshall_floyd(ll n, vector<vector<ll>> g, ll INF) { // init vector<vector<ll>> c(10,vector<ll>(10,0)); for (int k = 0; k < n; k++) { for (int i = 0; i < n; i++) { for (int j = 0; j < n; j++) { if (g[i][k] == INF || g[k][j] == INF) continue; g[i][j] = min(g[i][j], g[i][k] + g[k][j]); } } } return g; } struct Dijkstra { ll n; vector<vector<pair<ll, ll>>> Edges; vector<ll> Dist; vector<ll> Prev; vector<ll> PathNum; Dijkstra(ll n) : n(n), Edges(n), Dist(n), Prev(n), PathNum(n) { Prev.assign(n, -1); }; void add_edge(ll a, ll b, ll c, bool directed = true) { if (directed) { Edges[a].emplace_back(make_pair(b, c)); } else { Edges[a].emplace_back(make_pair(b, c)); Edges[b].emplace_back(make_pair(a, c)); } } // O((E+V)logV) void build(int start) { priority_queue<P, vector<P>, greater<P>> queue; fill(Dist.begin(), Dist.end(), 1e+18); // 1e18 !?!? fill(Prev.begin(), Prev.end(), -1); // 1e18 !?!? Dist[start] = 0; PathNum[start] = 1; queue.push(PL(0, start)); while (!queue.empty()) { PL p = queue.top(); queue.pop(); int v = p.second; if (Dist[v] < p.first) continue; for (int i = 0; i < Edges[v].size(); i++) { PL e = Edges[v][i]; if (Dist[e.first] > Dist[v] + e.second) { Dist[e.first] = Dist[v] + e.second; queue.push(P(Dist[e.first], e.first)); Prev[e.first] = v; PathNum[e.first] = PathNum[v]; } else if (Dist[e.first] == Dist[v] + e.second) { PathNum[e.first] += PathNum[v]; PathNum[e.first] %= MOD; } } } } ll dist(ll t) { return Dist[t]; } vector<ll> get_path(ll t) { vector<ll> path; for (; t != -1; t = Prev[t]) { path.push_back(t); } reverse(path.begin(), path.end()); return path; } ll get_path_num(ll t) { return PathNum[t]; } // int solve() // { // ll v, e, r; // cin >> v >> e >> r; // Dijkstra dij(v); // for (int i = 0; i < e; i++) // { // ll a, b, c; // cin >> a >> b >> c; // dij.add_edge(a, b, c); // } // dij.build(r); // for (int i = 0; i < v; i++) // { // if (dij.dist(i) == 1e18) // { // cout << "INF" << endl; // } // else // { // cout << dij.dist(i) << endl; // cout << dij.get_path(i) << endl; // cout << dij.get_path_num(i) << endl; // } // } // return 0; // } }; struct CumulativeSum2D { int H; int W; vector<vector<ll>> data; CumulativeSum2D(int H, int W) : H(H), W(W), data(H + 1, vector<ll>(W + 1, 0LL)) {} void add(int x, int y, ll z) { data[x + 1][y + 1] += z; } void build() { for (int i = 1; i < data.size(); i++) { for (int j = 1; j < data[i].size(); j++) { data[i][j] += data[i][j - 1] + data[i - 1][j] - data[i - 1][j - 1]; } } } void print() { for (int i = 0; i <= H; i++) { for (int j = 0; j <= W; j++) { cout << data[i][j] << " "; } cout << endl; } } ll query(int sx, int sy, int gx, int gy) { return (data[gy][gx] - data[sy - 1][gx] - data[gy][sx - 1] + data[sy - 1][sx - 1]); } }; struct LCA { int n, h; vector<vector<int>> par; vector<vector<pair<int, int>>> v; vector<ll> depth, dis; LCA(int sz) : n(sz), v(n), depth(n), dis(n) { h = 1; while ((1 << h) < n) h++; par.assign(h, vector<int>(n, -1)); } void add_edge(int x, int y, int z) { v[x].push_back({y, z}); v[y].push_back({x, z}); } void dfs(int x, int p, int d, ll di) { par[0][x] = p; depth[x] = d; dis[x] = di; for (auto to : v[x]) if (to.first != p) dfs(to.first, x, d + 1, di + to.second); } void build() { dfs(0, -1, 0, 0); for (int i = 0; i < h - 1; i++) { for (int j = 0; j < n; j++) { if (par[i][j] < 0) par[i + 1][j] = -1; else par[i + 1][j] = par[i][par[i][j]]; } } } int lca(int u, int v) { if (depth[u] > depth[v]) swap(u, v); for (int i = 0; i < h; i++) if ((depth[v] - depth[u]) >> i & 1) v = par[i][v]; if (u == v) return u; for (int i = h - 1; i >= 0; i--) { if (par[i][u] != par[i][v]) { u = par[i][u]; v = par[i][v]; } } return par[0][u]; } ll dist(int u, int v) { return dis[u] + dis[v] - 2 * dis[lca(u, v)]; } // int solve() // { // ll n; // cin >> n; // LCA lca(n); // for (int i = 0; i < n - 1; i++) // { // ll u, v, w; // cin >> u >> v >> w; // lca.add_edge(u, v, w); // } // lca.build(); // ll q; // cin >> q; // while (q--) // { // ll a, b, c; // cin >> a >> b >> c; // cout << (lca.dist(a, b) + lca.dist(b, c) + lca.dist(c, a)) / 2 << // endl; // } // return 0; // } }; vector<ll> compress(vector<ll> r) { // 1-indexed set<ll> se; for (int i = 0; i < r.size(); i++) { se.insert(r[i]); } map<ll, ll> m; ll cnt = 1; for (auto t : se) { m[t] = cnt; cnt++; } for (int i = 0; i < r.size(); i++) { r[i] = m[r[i]]; } return r; } template <class Abel> struct WeightedUnionFind { vector<int> par; vector<int> rank; vector<Abel> diff_weight; WeightedUnionFind(int n = 1, Abel SUM_UNITY = 0) { init(n, SUM_UNITY); } void init(int n = 1, Abel SUM_UNITY = 0) { par.resize(n); rank.resize(n); diff_weight.resize(n); for (int i = 0; i < n; ++i) par[i] = i, rank[i] = 0, diff_weight[i] = SUM_UNITY; } int root(int x) { if (par[x] == x) { return x; } else { int r = root(par[x]); diff_weight[x] += diff_weight[par[x]]; return par[x] = r; } } Abel weight(int x) { root(x); return diff_weight[x]; } bool issame(int x, int y) { return root(x) == root(y); } bool merge(int x, int y, Abel w) { w += weight(x); w -= weight(y); x = root(x); y = root(y); if (x == y) return false; if (rank[x] < rank[y]) swap(x, y), w = -w; if (rank[x] == rank[y]) ++rank[x]; par[y] = x; diff_weight[y] = w; return true; } Abel diff(int x, int y) { return weight(y) - weight(x); } }; void YES() { cout << "YES" << endl; exit(0); } void NO() { cout << "NO" << endl; exit(0); } void Yes() { cout << "Yes" << endl; exit(0); } void No() { cout << "No" << endl; exit(0); } void m1() { cout << -1 << endl; exit(0); } template <typename T> void out(const T t) { cout << t << '\n'; } template <typename T> void fout(const T t) { cout << fixed << setprecision(10) << t << '\n'; } /*------------------------------*/ void solve() { ll n; cin >> n; vector<ll> b(n); for (int i = 0; i < n; i++) { cin >> b[i]; } map<ll, ll> cnt; vector<ll> ans; for (int i = n; i >= 1; i--) { ll v = i; ll t = 0; while (v > n) { v += i; t += cnt[v]; } if (t % 2 != b[i - 1]) { ans.push_back(i); cnt[i]++; } } if (ans.size() == 0) { out(0); } else { out(ans.size()); cout << (ans[0]); for (int i = 1; i < ans.size(); i++) { cout << " " << ans[i]; } cout << endl; } } // g++.exe bbb.cpp -std=c++14 int main() { cout.precision(10); ios::sync_with_stdio(false); cin.tie(0); solve(); return 0; } // IMOSs//https://imoz.jp/algorithms/imos_method.html /*名前 accumulate(ALL(b),0LL) prev_permutation(ALL(v)) 辞書順で一個前の順列を構築する bitcount __builtin_popcountll 二次元累積和 CumulativeSum2D 10進数の桁和 digit_sum (b*b+c*c)**0.5 hypot cout << fixed << setprecision(10) << ans << endl; // 文字列t ->整数 atoi(t.c_str()); // 文字列t ->long long整数 stoll(t); ローカルではつかえない */ /* L=(1,0,1,1,3,4) C(1,3,0,1,1) 配列Lの中で x 以上 y 未満の値が何個あるのかが、累積和を使うとわかる。 具体的には C の累積和を S とすると、S[ y ] - S[ x ] で求められる */ /*実装例 zaatu sort(ALL(c)); c.erase(unique(ALL(c)), end(c)); ********** DP ********** ・ナップサックDP https://onlinejudge.u-aizu.ac.jp/courses/library/7/DPL/all/DPL_1_C 個数制限なしナップサック N<=100,W<=10000,v<=1000 https://onlinejudge.u-aizu.ac.jp/courses/library/7/DPL/all/DPL_1_B 01ナップサック N<=100,W<=10000,v<=1000 https://onlinejudge.u-aizu.ac.jp/courses/library/7/DPL/all/DPL_1_F 01ナップサック N<=100,W<=10^9,v<=100 https://onlinejudge.u-aizu.ac.jp/courses/library/7/DPL/1/DPL_1_H 巨大ナップザック N=40 w<10^15 , v<10^15 解)半分全列挙して、wi > wj かつvi < vj となるようなiを除いて、二分探索 ・部分文字列DP https://qiita.com/drken/items/a207e5ae3ea2cf17f4bd next[i][c] := S の i 文字目以降で最初に文字 c が登場する index https://www.hackerrank.com/contests/bbc003/challenges/bbc003-e/submissions/code/1321355726 (部分文字列の中で+の個数の偶奇によって、カウントするか決める) No.852 連続部分文字列 https://yukicoder.me/problems/no/852/editorial 連続な部分文字列における、文字の種類数の平均を求める 解)右端を固定すると dp[i+1] = dp[i] + (左にs[i]がでてきた位置との距離) E - Common Subsequence https://atcoder.jp/contests/abc130/tasks/abc130_e 文字列S、Tの共通整数列の数を求める 遷移はLCSのようにできるが、重複が発生するので除く必要がある ・桁DP 1 https://atcoder.jp/contests/abc029/tasks/abc029_d n以下の数字の中で現れた1の数を求める dp[i][j][k]:i桁目まで見たときに1の個数がk個の数字の個数 S - Digit Sum https://atcoder.jp/contests/dp/tasks/dp_s n以下の数字の中で、各桁の総和がDの倍数となるものを数える E - Almost Everywhere Zero https://atcoder.jp/contests/abc154/tasks/abc154_e n以下の数字の中で,0でない数字が丁度K個あるものの数を数える E - Sum Equals Xor https://atcoder.jp/contests/abc129/tasks/abc129_e a+b<=L,a+b=a^bとなる(a,b)を数える ************* 組み合わせ ************* https://codeforces.com/contest/888/problem/D 少なくともn-k個がpi=iとなるような順列の組の数え上げ →pi≠iとなる順列をモンモール数という。n-k~n個をpi=iと固定したときに、他の要素がpi≠iとなるような組み合わせの数(モンモール数)の積をとる https://codeforces.com/problemset/problem/322/B 赤・青・緑の花束が存在し、ある色を3本or全ての色を1本ずつ使ったときに、できる花束の最大数 https://atcoder.jp/contests/abc021/tasks/abc021_d https://codeforces.com/problemset/problem/1288/C 1 <=a1 <= a2 <= ... <= ak <= n となる(a1,a2..ak)の組の数 →等号がなければ単純にn個の要素の中からk個を選べばよい -> C(n,k) →等号がある場合は重複を許してk個選べばよい      -> H(n,k) http://codeforces.com/contest/1312/problem/D aj < aj+i < ... ai > ....ak > ak+1 かつ同じ数字のペアが一つだけ含まれるような組の数 D - Blue and Red Balls https://atcoder.jp/contests/abc132/tasks/abc132_d 青と赤のボールを並べ、連続している青を1~k個作ったときの並べ方の数 ************* 最短経路 ************* https://atcoder.jp/contests/joi2014yo/tasks/joi2014yo_e 移動できるノード数に制限がある場合の最短経路問題 →事前に幅優先探索でノード毎に移動できるノードを求めて、ダイクストラ ************* 遅延セグ木 ************* https://atcoder.jp/contests/abc153/submissions/10165699 *********** BIT *********** https://atcoder.jp/contests/abc157/tasks/abc157_e(アルファベット毎にBITもつやつ) https://hoj.hamako-ths.ed.jp/onlinejudge/problems/1276(中央値求めるやつ) *********** 数学 *********** 大きい数の約数 https://yukicoder.me/problems/no/677 10^nの全ての正の約数を列挙 →10^kは素因数として2^k,5^kしかもたないので、それぞれをかけ合わせる 例えば10は2^1*5*1なので、2^0,2^1に5^0,5^1をそれぞれかけ合わせればよい。 */
#include <algorithm> #include <cassert> #include <cmath> #include <cstdio> #include <cstdlib> #include <cstring> #include <functional> #include <iomanip> #include <iostream> #include <map> #include <numeric> #include <queue> #include <set> #include <string> #include <unordered_map> #include <unordered_set> #include <vector> using namespace std; typedef long long ll; typedef pair<ll, ll> P; typedef pair<ll, ll> PL; const ll mod = 1000000007; // const ll mod = 998244353; const ll MOD = 1000000007; const ll INF = 1LL << 60; #define PI (acos(-1)) #define ALL(c) (c).begin(), (c).end() #define en '\n' #define endl '\n' template <typename T> istream &operator>>(istream &is, vector<T> &vec) { for (auto &v : vec) is >> v; return is; } template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec) { os << "["; for (auto v : vec) os << v << ","; os << "]"; return os; } template <typename T> ostream &operator<<(ostream &os, const deque<T> &vec) { os << "deq["; for (auto v : vec) os << v << ","; os << "]"; return os; } template <typename T> ostream &operator<<(ostream &os, const set<T> &vec) { os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; } template <typename T> ostream &operator<<(ostream &os, const multiset<T> &vec) { os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; } template <typename T1, typename T2> ostream &operator<<(ostream &os, const pair<T1, T2> &pa) { os << "(" << pa.first << "," << pa.second << ")"; return os; } template <typename TK, typename TV> ostream &operator<<(ostream &os, const map<TK, TV> &mp) { os << "{"; for (auto v : mp) os << v.first << "=>" << v.second << ","; os << "}"; return os; } #define dbg(x) \ cerr << #x << " = " << (x) << " (L" << __LINE__ << ") " << __FILE__ << endl; // template <typename A, size_t N, typename T> template <typename T> inline string toString(const T &a) { ostringstream oss; oss << a; return oss.str(); }; template <int mod> struct ModInt { int x; ModInt() : x(0) {} ModInt(int64_t y) : x(y >= 0 ? y % mod : (mod - (-y) % mod) % mod) {} ModInt &operator+=(const ModInt &p) { if ((x += p.x) >= mod) x -= mod; return *this; } ModInt &operator-=(const ModInt &p) { if ((x += mod - p.x) >= mod) x -= mod; return *this; } ModInt &operator*=(const ModInt &p) { x = (int)(1LL * x * p.x % mod); return *this; } ModInt &operator/=(const ModInt &p) { *this *= p.inverse(); return *this; } ModInt operator-() const { return ModInt(-x); } ModInt operator+(const ModInt &p) const { return ModInt(*this) += p; } ModInt operator-(const ModInt &p) const { return ModInt(*this) -= p; } ModInt operator*(const ModInt &p) const { return ModInt(*this) *= p; } ModInt operator/(const ModInt &p) const { return ModInt(*this) /= p; } bool operator==(const ModInt &p) const { return x == p.x; } bool operator!=(const ModInt &p) const { return x != p.x; } ModInt inverse() const { int a = x, b = mod, u = 1, v = 0, t; while (b > 0) { t = a / b; swap(a -= t * b, b); swap(u -= t * v, v); } return ModInt(u); } ModInt pow(int64_t n) const { ModInt ret(1), mul(x); while (n > 0) { if (n & 1) ret *= mul; mul *= mul; n >>= 1; } return ret; } friend ostream &operator<<(ostream &os, const ModInt &p) { return os << p.x; } friend istream &operator>>(istream &is, ModInt &a) { int64_t t; is >> t; a = ModInt<mod>(t); return (is); } static int get_mod() { return mod; } }; using modint = ModInt<mod>; template <typename T> struct Combination { vector<T> _fact, _rfact, _inv; Combination(int sz) : _fact(sz + 1), _rfact(sz + 1), _inv(sz + 1) { _fact[0] = _rfact[sz] = _inv[0] = 1; for (int i = 1; i <= sz; i++) _fact[i] = _fact[i - 1] * i; _rfact[sz] /= _fact[sz]; for (int i = sz - 1; i >= 0; i--) _rfact[i] = _rfact[i + 1] * (i + 1); for (int i = 1; i <= sz; i++) _inv[i] = _rfact[i] * _fact[i - 1]; } inline T fact(int k) const { return _fact[k]; } inline T rfact(int k) const { return _rfact[k]; } inline T inv(int k) const { return _inv[k]; } T P(int n, int r) const { if (r < 0 || n < r) return 0; return fact(n) * rfact(n - r); } T C(int p, int q) const { if (q < 0 || p < q) return 0; return fact(p) * rfact(q) * rfact(p - q); } T H(int n, int r) const { if (n < 0 || r < 0) return (0); return r == 0 ? 1 : C(n + r - 1, r); } T NC(int p, int q) const { modint ret = 1; for (int i = 1; i <= q; i += 1) { ret = ret * p / i; p--; } return ret; } }; ll lcm(ll a, ll b) { return a / __gcd(a, b) * b; } bool is_prime(ll x) { if (x == 1) { return false; } for (ll i = 2; i * i <= x; i++) { if (x % i == 0) return false; } return true; } map<ll, int> prime_factor(ll n) { map<ll, int> ret; for (ll i = 2; i * i <= n; i++) { while (n % i == 0) { ret[i]++; n /= i; } } if (n != 1) ret[n] = 1; return ret; } vector<ll> divisor(ll n) { vector<ll> ret; for (ll i = 1; i * i <= n; i++) { if (n % i == 0) { ret.push_back(i); if (i * i != n) ret.push_back(n / i); } } sort(begin(ret), end(ret)); return (ret); } long long modpow(long long a, long long n, long long mod) { long long res = 1; while (n > 0) { if (n & 1) res = res * a % mod; a = a * a % mod; n >>= 1; } return res; } long long modinv(long long a, long long mod) { return modpow(a, mod - 2, mod); } const ll MAX = 510000; ll fac[MAX], finv[MAX], inv[MAX]; void COMinit() { fac[0] = fac[1] = 1; finv[0] = finv[1] = 1; inv[1] = 1; for (ll i = 2; i < MAX; i++) { fac[i] = fac[i - 1] * i % MOD; inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD; finv[i] = finv[i - 1] * inv[i] % MOD; } } ll COM(ll n, ll k) { if (n < k) return 0; if (n < 0 || k < 0) return 0; return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD; } struct UnionFind { vector<int> par; UnionFind(int n) : par(n, -1) {} void init(int n) { par.assign(n, -1); } int root(int x) { if (par[x] < 0) return x; else return par[x] = root(par[x]); } bool issame(int x, int y) { return root(x) == root(y); } bool merge(int x, int y) { x = root(x); y = root(y); if (x == y) return false; if (par[x] > par[y]) swap(x, y); // merge technique par[x] += par[y]; par[y] = x; return true; } int size(int x) { return -par[root(x)]; } }; struct BIT { // 1-indexed!!! int n; vector<int> bit; BIT() { init(); } BIT(int n) : n(n) { init(); } void init() { bit.clear(); bit.resize(n + 1, 0); } int sum(int i) { int s = 0; while (i > 0) { s += bit[i]; i -= i & -i; } return s; } int sum(int x, int y) { return sum(y) - sum(x - 1); } void add(int i, int x) { while (i <= n) { bit[i] += x; i += i & -i; } } int lower_bound(int w) { if (w <= 0) return 0; int x = 0, r = 1; while (r < n) r <<= 1; for (int k = r; k > 0; k >>= 1) { if (x + k <= n && bit[x + k] < w) { w -= bit[x + k]; x += k; } } return x + 1; } }; struct LazySegmentTree { // private: ll n; vector<ll> node, lazy; // public: LazySegmentTree(vector<ll> v) { int sz = (int)v.size(); n = 1; while (n < sz) n *= 2; node.resize(2 * n - 1); lazy.resize(2 * n - 1, 0); for (int i = 0; i < sz; i++) node[i + n - 1] = v[i]; for (int i = n - 2; i >= 0; i--) node[i] = node[i * 2 + 1] + node[i * 2 + 2]; } void eval(int k, int l, int r) { if (lazy[k] != 0) { node[k] += lazy[k]; if (r - l > 1) { lazy[2 * k + 1] += lazy[k] / 2; lazy[2 * k + 2] += lazy[k] / 2; } lazy[k] = 0; } } void add(int a, int b, ll x, int k = 0, int l = 0, int r = -1) { if (r < 0) r = n; eval(k, l, r); if (b <= l || r <= a) return; if (a <= l && r <= b) { lazy[k] += (r - l) * x; eval(k, l, r); } else { add(a, b, x, 2 * k + 1, l, (l + r) / 2); add(a, b, x, 2 * k + 2, (l + r) / 2, r); node[k] = node[2 * k + 1] + node[2 * k + 2]; } } ll getsum(int a, int b, int k = 0, int l = 0, int r = -1) { if (r < 0) r = n; eval(k, l, r); if (b <= l || r <= a) return 0; if (a <= l && r <= b) return node[k]; ll vl = getsum(a, b, 2 * k + 1, l, (l + r) / 2); ll vr = getsum(a, b, 2 * k + 2, (l + r) / 2, r); return vl + vr; } }; ll digit_sum(ll v) { ll ret = 0; while (v) { ret += (v % 10); v /= 10; } return ret; } template <typename T> struct Kruskal { struct edge { ll from, to; T cost; ll used; edge() {} edge(ll from, ll to, T cost) : from(from), to(to), cost(cost), used(0) {} bool operator<(const edge &e) const { return cost < e.cost; } }; ll n; vector<ll> p, r; vector<edge> edges; Kruskal() {} Kruskal(ll n) : n(n) {} void init(ll n) { r.assign(n, 1); p.resize(n); iota(p.begin(), p.end(), 0); } ll find(ll x) { return (x == p[x] ? x : p[x] = find(p[x])); } bool same(ll x, ll y) { return find(x) == find(y); } void unite(ll x, ll y) { x = find(x); y = find(y); if (x == y) return; if (r[x] < r[y]) swap(x, y); r[x] += r[y]; p[y] = x; } void add_edge(ll u, ll v, T c) { edges.emplace_back(u, v, c); } T build() { sort(edges.begin(), edges.end()); init(n); T res = 0; for (auto &e : edges) { if (!same(e.from, e.to)) { res += e.cost; unite(e.from, e.to); e.used = 1; } } return res; } T build(ll k) { sort(edges.begin(), edges.end()); init(n); T res = 0; ll cnt = 0; for (auto &e : edges) { if (!same(e.from, e.to)) { res += e.cost; unite(e.from, e.to); e.used = 1; cnt++; } if (cnt == k) { break; } } return res; } }; int LIS(int a[], int n) { vector<int> A(n, 0x3f3f3f3f); for (int i = 0; i < n; i++) *lower_bound(A.begin(), A.end(), a[i]) = a[i]; return find(A.begin(), A.end(), 0x3f3f3f3f) - A.begin(); } // string maze[1010]; // //ll maze[100][100]; // ll grid_bfs(ll H, ll W, ll sx, ll sy, ll gx, ll gy) // { // //O(E) // int dx[4] = {1, 0, -1, 0}; // int dy[4] = {0, 1, 0, -1}; // vector<vector<ll>> dist(H, vector<ll>(W, -1)); // dist[sy][sx] = 0; // queue<PL> q; // q.push({sy, sx}); // while (!q.empty()) // { // ll x, y; // tie(y, x) = q.front(); // q.pop(); // if (y == gy && x == gx) // { // break; // } // for (int t = 0; t < 4; t++) // { // ll nx = x + dx[t], ny = y + dy[t]; // if (nx < 0 || ny < 0 || nx >= W || ny >= H || dist[ny][nx] != -1 // || maze[ny][nx] == '#') // { // continue; // } // dist[ny][nx] = dist[y][x] + 1; // q.push({ny, nx}); // } // } // return dist[gy][gx]; // } // no verify ll bfs(ll n, ll start, vector<vector<PL>> Edges) { vector<ll> dist(n + 1, -1); dist[start] = 0; queue<PL> q; q.push({start, 0}); while (!q.empty()) { ll node, cost; tie(cost, node) = q.front(); q.pop(); for (auto p : Edges[node]) { ll v = p.first, cost = p.second; if (dist[v] == -1) { dist[v] = dist[node] + cost; q.push({v, cost}); } } } } vector<vector<ll>> warshall_floyd(ll n, vector<vector<ll>> g, ll INF) { // init vector<vector<ll>> c(10,vector<ll>(10,0)); for (int k = 0; k < n; k++) { for (int i = 0; i < n; i++) { for (int j = 0; j < n; j++) { if (g[i][k] == INF || g[k][j] == INF) continue; g[i][j] = min(g[i][j], g[i][k] + g[k][j]); } } } return g; } struct Dijkstra { ll n; vector<vector<pair<ll, ll>>> Edges; vector<ll> Dist; vector<ll> Prev; vector<ll> PathNum; Dijkstra(ll n) : n(n), Edges(n), Dist(n), Prev(n), PathNum(n) { Prev.assign(n, -1); }; void add_edge(ll a, ll b, ll c, bool directed = true) { if (directed) { Edges[a].emplace_back(make_pair(b, c)); } else { Edges[a].emplace_back(make_pair(b, c)); Edges[b].emplace_back(make_pair(a, c)); } } // O((E+V)logV) void build(int start) { priority_queue<P, vector<P>, greater<P>> queue; fill(Dist.begin(), Dist.end(), 1e+18); // 1e18 !?!? fill(Prev.begin(), Prev.end(), -1); // 1e18 !?!? Dist[start] = 0; PathNum[start] = 1; queue.push(PL(0, start)); while (!queue.empty()) { PL p = queue.top(); queue.pop(); int v = p.second; if (Dist[v] < p.first) continue; for (int i = 0; i < Edges[v].size(); i++) { PL e = Edges[v][i]; if (Dist[e.first] > Dist[v] + e.second) { Dist[e.first] = Dist[v] + e.second; queue.push(P(Dist[e.first], e.first)); Prev[e.first] = v; PathNum[e.first] = PathNum[v]; } else if (Dist[e.first] == Dist[v] + e.second) { PathNum[e.first] += PathNum[v]; PathNum[e.first] %= MOD; } } } } ll dist(ll t) { return Dist[t]; } vector<ll> get_path(ll t) { vector<ll> path; for (; t != -1; t = Prev[t]) { path.push_back(t); } reverse(path.begin(), path.end()); return path; } ll get_path_num(ll t) { return PathNum[t]; } // int solve() // { // ll v, e, r; // cin >> v >> e >> r; // Dijkstra dij(v); // for (int i = 0; i < e; i++) // { // ll a, b, c; // cin >> a >> b >> c; // dij.add_edge(a, b, c); // } // dij.build(r); // for (int i = 0; i < v; i++) // { // if (dij.dist(i) == 1e18) // { // cout << "INF" << endl; // } // else // { // cout << dij.dist(i) << endl; // cout << dij.get_path(i) << endl; // cout << dij.get_path_num(i) << endl; // } // } // return 0; // } }; struct CumulativeSum2D { int H; int W; vector<vector<ll>> data; CumulativeSum2D(int H, int W) : H(H), W(W), data(H + 1, vector<ll>(W + 1, 0LL)) {} void add(int x, int y, ll z) { data[x + 1][y + 1] += z; } void build() { for (int i = 1; i < data.size(); i++) { for (int j = 1; j < data[i].size(); j++) { data[i][j] += data[i][j - 1] + data[i - 1][j] - data[i - 1][j - 1]; } } } void print() { for (int i = 0; i <= H; i++) { for (int j = 0; j <= W; j++) { cout << data[i][j] << " "; } cout << endl; } } ll query(int sx, int sy, int gx, int gy) { return (data[gy][gx] - data[sy - 1][gx] - data[gy][sx - 1] + data[sy - 1][sx - 1]); } }; struct LCA { int n, h; vector<vector<int>> par; vector<vector<pair<int, int>>> v; vector<ll> depth, dis; LCA(int sz) : n(sz), v(n), depth(n), dis(n) { h = 1; while ((1 << h) < n) h++; par.assign(h, vector<int>(n, -1)); } void add_edge(int x, int y, int z) { v[x].push_back({y, z}); v[y].push_back({x, z}); } void dfs(int x, int p, int d, ll di) { par[0][x] = p; depth[x] = d; dis[x] = di; for (auto to : v[x]) if (to.first != p) dfs(to.first, x, d + 1, di + to.second); } void build() { dfs(0, -1, 0, 0); for (int i = 0; i < h - 1; i++) { for (int j = 0; j < n; j++) { if (par[i][j] < 0) par[i + 1][j] = -1; else par[i + 1][j] = par[i][par[i][j]]; } } } int lca(int u, int v) { if (depth[u] > depth[v]) swap(u, v); for (int i = 0; i < h; i++) if ((depth[v] - depth[u]) >> i & 1) v = par[i][v]; if (u == v) return u; for (int i = h - 1; i >= 0; i--) { if (par[i][u] != par[i][v]) { u = par[i][u]; v = par[i][v]; } } return par[0][u]; } ll dist(int u, int v) { return dis[u] + dis[v] - 2 * dis[lca(u, v)]; } // int solve() // { // ll n; // cin >> n; // LCA lca(n); // for (int i = 0; i < n - 1; i++) // { // ll u, v, w; // cin >> u >> v >> w; // lca.add_edge(u, v, w); // } // lca.build(); // ll q; // cin >> q; // while (q--) // { // ll a, b, c; // cin >> a >> b >> c; // cout << (lca.dist(a, b) + lca.dist(b, c) + lca.dist(c, a)) / 2 << // endl; // } // return 0; // } }; vector<ll> compress(vector<ll> r) { // 1-indexed set<ll> se; for (int i = 0; i < r.size(); i++) { se.insert(r[i]); } map<ll, ll> m; ll cnt = 1; for (auto t : se) { m[t] = cnt; cnt++; } for (int i = 0; i < r.size(); i++) { r[i] = m[r[i]]; } return r; } template <class Abel> struct WeightedUnionFind { vector<int> par; vector<int> rank; vector<Abel> diff_weight; WeightedUnionFind(int n = 1, Abel SUM_UNITY = 0) { init(n, SUM_UNITY); } void init(int n = 1, Abel SUM_UNITY = 0) { par.resize(n); rank.resize(n); diff_weight.resize(n); for (int i = 0; i < n; ++i) par[i] = i, rank[i] = 0, diff_weight[i] = SUM_UNITY; } int root(int x) { if (par[x] == x) { return x; } else { int r = root(par[x]); diff_weight[x] += diff_weight[par[x]]; return par[x] = r; } } Abel weight(int x) { root(x); return diff_weight[x]; } bool issame(int x, int y) { return root(x) == root(y); } bool merge(int x, int y, Abel w) { w += weight(x); w -= weight(y); x = root(x); y = root(y); if (x == y) return false; if (rank[x] < rank[y]) swap(x, y), w = -w; if (rank[x] == rank[y]) ++rank[x]; par[y] = x; diff_weight[y] = w; return true; } Abel diff(int x, int y) { return weight(y) - weight(x); } }; void YES() { cout << "YES" << endl; exit(0); } void NO() { cout << "NO" << endl; exit(0); } void Yes() { cout << "Yes" << endl; exit(0); } void No() { cout << "No" << endl; exit(0); } void m1() { cout << -1 << endl; exit(0); } template <typename T> void out(const T t) { cout << t << '\n'; } template <typename T> void fout(const T t) { cout << fixed << setprecision(10) << t << '\n'; } /*------------------------------*/ void solve() { ll n; cin >> n; vector<ll> b(n); for (int i = 0; i < n; i++) { cin >> b[i]; } map<ll, ll> cnt; vector<ll> ans; for (int i = n; i >= 1; i--) { ll v = i; ll t = 0; while (v <= n) { v += i; t += cnt[v]; } if (t % 2 != b[i - 1]) { ans.push_back(i); cnt[i]++; } } if (ans.size() == 0) { out(0); } else { out(ans.size()); cout << (ans[0]); for (int i = 1; i < ans.size(); i++) { cout << " " << ans[i]; } cout << endl; } } // g++.exe bbb.cpp -std=c++14 int main() { cout.precision(10); ios::sync_with_stdio(false); cin.tie(0); solve(); return 0; } // IMOSs//https://imoz.jp/algorithms/imos_method.html /*名前 accumulate(ALL(b),0LL) prev_permutation(ALL(v)) 辞書順で一個前の順列を構築する bitcount __builtin_popcountll 二次元累積和 CumulativeSum2D 10進数の桁和 digit_sum (b*b+c*c)**0.5 hypot cout << fixed << setprecision(10) << ans << endl; // 文字列t ->整数 atoi(t.c_str()); // 文字列t ->long long整数 stoll(t); ローカルではつかえない */ /* L=(1,0,1,1,3,4) C(1,3,0,1,1) 配列Lの中で x 以上 y 未満の値が何個あるのかが、累積和を使うとわかる。 具体的には C の累積和を S とすると、S[ y ] - S[ x ] で求められる */ /*実装例 zaatu sort(ALL(c)); c.erase(unique(ALL(c)), end(c)); ********** DP ********** ・ナップサックDP https://onlinejudge.u-aizu.ac.jp/courses/library/7/DPL/all/DPL_1_C 個数制限なしナップサック N<=100,W<=10000,v<=1000 https://onlinejudge.u-aizu.ac.jp/courses/library/7/DPL/all/DPL_1_B 01ナップサック N<=100,W<=10000,v<=1000 https://onlinejudge.u-aizu.ac.jp/courses/library/7/DPL/all/DPL_1_F 01ナップサック N<=100,W<=10^9,v<=100 https://onlinejudge.u-aizu.ac.jp/courses/library/7/DPL/1/DPL_1_H 巨大ナップザック N=40 w<10^15 , v<10^15 解)半分全列挙して、wi > wj かつvi < vj となるようなiを除いて、二分探索 ・部分文字列DP https://qiita.com/drken/items/a207e5ae3ea2cf17f4bd next[i][c] := S の i 文字目以降で最初に文字 c が登場する index https://www.hackerrank.com/contests/bbc003/challenges/bbc003-e/submissions/code/1321355726 (部分文字列の中で+の個数の偶奇によって、カウントするか決める) No.852 連続部分文字列 https://yukicoder.me/problems/no/852/editorial 連続な部分文字列における、文字の種類数の平均を求める 解)右端を固定すると dp[i+1] = dp[i] + (左にs[i]がでてきた位置との距離) E - Common Subsequence https://atcoder.jp/contests/abc130/tasks/abc130_e 文字列S、Tの共通整数列の数を求める 遷移はLCSのようにできるが、重複が発生するので除く必要がある ・桁DP 1 https://atcoder.jp/contests/abc029/tasks/abc029_d n以下の数字の中で現れた1の数を求める dp[i][j][k]:i桁目まで見たときに1の個数がk個の数字の個数 S - Digit Sum https://atcoder.jp/contests/dp/tasks/dp_s n以下の数字の中で、各桁の総和がDの倍数となるものを数える E - Almost Everywhere Zero https://atcoder.jp/contests/abc154/tasks/abc154_e n以下の数字の中で,0でない数字が丁度K個あるものの数を数える E - Sum Equals Xor https://atcoder.jp/contests/abc129/tasks/abc129_e a+b<=L,a+b=a^bとなる(a,b)を数える ************* 組み合わせ ************* https://codeforces.com/contest/888/problem/D 少なくともn-k個がpi=iとなるような順列の組の数え上げ →pi≠iとなる順列をモンモール数という。n-k~n個をpi=iと固定したときに、他の要素がpi≠iとなるような組み合わせの数(モンモール数)の積をとる https://codeforces.com/problemset/problem/322/B 赤・青・緑の花束が存在し、ある色を3本or全ての色を1本ずつ使ったときに、できる花束の最大数 https://atcoder.jp/contests/abc021/tasks/abc021_d https://codeforces.com/problemset/problem/1288/C 1 <=a1 <= a2 <= ... <= ak <= n となる(a1,a2..ak)の組の数 →等号がなければ単純にn個の要素の中からk個を選べばよい -> C(n,k) →等号がある場合は重複を許してk個選べばよい      -> H(n,k) http://codeforces.com/contest/1312/problem/D aj < aj+i < ... ai > ....ak > ak+1 かつ同じ数字のペアが一つだけ含まれるような組の数 D - Blue and Red Balls https://atcoder.jp/contests/abc132/tasks/abc132_d 青と赤のボールを並べ、連続している青を1~k個作ったときの並べ方の数 ************* 最短経路 ************* https://atcoder.jp/contests/joi2014yo/tasks/joi2014yo_e 移動できるノード数に制限がある場合の最短経路問題 →事前に幅優先探索でノード毎に移動できるノードを求めて、ダイクストラ ************* 遅延セグ木 ************* https://atcoder.jp/contests/abc153/submissions/10165699 *********** BIT *********** https://atcoder.jp/contests/abc157/tasks/abc157_e(アルファベット毎にBITもつやつ) https://hoj.hamako-ths.ed.jp/onlinejudge/problems/1276(中央値求めるやつ) *********** 数学 *********** 大きい数の約数 https://yukicoder.me/problems/no/677 10^nの全ての正の約数を列挙 →10^kは素因数として2^k,5^kしかもたないので、それぞれをかけ合わせる 例えば10は2^1*5*1なので、2^0,2^1に5^0,5^1をそれぞれかけ合わせればよい。 */
[ "expression.operator.compare.change", "control_flow.loop.condition.change" ]
778,076
778,077
u644778646
cpp
p02972
#include <algorithm> #include <cassert> #include <cmath> #include <cstdio> #include <cstdlib> #include <cstring> #include <functional> #include <iomanip> #include <iostream> #include <map> #include <numeric> #include <queue> #include <set> #include <string> #include <unordered_map> #include <unordered_set> #include <vector> using namespace std; typedef long long ll; typedef pair<ll, ll> P; typedef pair<ll, ll> PL; const ll mod = 1000000007; // const ll mod = 998244353; const ll MOD = 1000000007; const ll INF = 1LL << 60; #define PI (acos(-1)) #define ALL(c) (c).begin(), (c).end() #define en '\n' #define endl '\n' template <typename T> istream &operator>>(istream &is, vector<T> &vec) { for (auto &v : vec) is >> v; return is; } template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec) { os << "["; for (auto v : vec) os << v << ","; os << "]"; return os; } template <typename T> ostream &operator<<(ostream &os, const deque<T> &vec) { os << "deq["; for (auto v : vec) os << v << ","; os << "]"; return os; } template <typename T> ostream &operator<<(ostream &os, const set<T> &vec) { os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; } template <typename T> ostream &operator<<(ostream &os, const multiset<T> &vec) { os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; } template <typename T1, typename T2> ostream &operator<<(ostream &os, const pair<T1, T2> &pa) { os << "(" << pa.first << "," << pa.second << ")"; return os; } template <typename TK, typename TV> ostream &operator<<(ostream &os, const map<TK, TV> &mp) { os << "{"; for (auto v : mp) os << v.first << "=>" << v.second << ","; os << "}"; return os; } #define dbg(x) \ cerr << #x << " = " << (x) << " (L" << __LINE__ << ") " << __FILE__ << endl; // template <typename A, size_t N, typename T> template <typename T> inline string toString(const T &a) { ostringstream oss; oss << a; return oss.str(); }; template <int mod> struct ModInt { int x; ModInt() : x(0) {} ModInt(int64_t y) : x(y >= 0 ? y % mod : (mod - (-y) % mod) % mod) {} ModInt &operator+=(const ModInt &p) { if ((x += p.x) >= mod) x -= mod; return *this; } ModInt &operator-=(const ModInt &p) { if ((x += mod - p.x) >= mod) x -= mod; return *this; } ModInt &operator*=(const ModInt &p) { x = (int)(1LL * x * p.x % mod); return *this; } ModInt &operator/=(const ModInt &p) { *this *= p.inverse(); return *this; } ModInt operator-() const { return ModInt(-x); } ModInt operator+(const ModInt &p) const { return ModInt(*this) += p; } ModInt operator-(const ModInt &p) const { return ModInt(*this) -= p; } ModInt operator*(const ModInt &p) const { return ModInt(*this) *= p; } ModInt operator/(const ModInt &p) const { return ModInt(*this) /= p; } bool operator==(const ModInt &p) const { return x == p.x; } bool operator!=(const ModInt &p) const { return x != p.x; } ModInt inverse() const { int a = x, b = mod, u = 1, v = 0, t; while (b > 0) { t = a / b; swap(a -= t * b, b); swap(u -= t * v, v); } return ModInt(u); } ModInt pow(int64_t n) const { ModInt ret(1), mul(x); while (n > 0) { if (n & 1) ret *= mul; mul *= mul; n >>= 1; } return ret; } friend ostream &operator<<(ostream &os, const ModInt &p) { return os << p.x; } friend istream &operator>>(istream &is, ModInt &a) { int64_t t; is >> t; a = ModInt<mod>(t); return (is); } static int get_mod() { return mod; } }; using modint = ModInt<mod>; template <typename T> struct Combination { vector<T> _fact, _rfact, _inv; Combination(int sz) : _fact(sz + 1), _rfact(sz + 1), _inv(sz + 1) { _fact[0] = _rfact[sz] = _inv[0] = 1; for (int i = 1; i <= sz; i++) _fact[i] = _fact[i - 1] * i; _rfact[sz] /= _fact[sz]; for (int i = sz - 1; i >= 0; i--) _rfact[i] = _rfact[i + 1] * (i + 1); for (int i = 1; i <= sz; i++) _inv[i] = _rfact[i] * _fact[i - 1]; } inline T fact(int k) const { return _fact[k]; } inline T rfact(int k) const { return _rfact[k]; } inline T inv(int k) const { return _inv[k]; } T P(int n, int r) const { if (r < 0 || n < r) return 0; return fact(n) * rfact(n - r); } T C(int p, int q) const { if (q < 0 || p < q) return 0; return fact(p) * rfact(q) * rfact(p - q); } T H(int n, int r) const { if (n < 0 || r < 0) return (0); return r == 0 ? 1 : C(n + r - 1, r); } T NC(int p, int q) const { modint ret = 1; for (int i = 1; i <= q; i += 1) { ret = ret * p / i; p--; } return ret; } }; ll lcm(ll a, ll b) { return a / __gcd(a, b) * b; } bool is_prime(ll x) { if (x == 1) { return false; } for (ll i = 2; i * i <= x; i++) { if (x % i == 0) return false; } return true; } map<ll, int> prime_factor(ll n) { map<ll, int> ret; for (ll i = 2; i * i <= n; i++) { while (n % i == 0) { ret[i]++; n /= i; } } if (n != 1) ret[n] = 1; return ret; } vector<ll> divisor(ll n) { vector<ll> ret; for (ll i = 1; i * i <= n; i++) { if (n % i == 0) { ret.push_back(i); if (i * i != n) ret.push_back(n / i); } } sort(begin(ret), end(ret)); return (ret); } long long modpow(long long a, long long n, long long mod) { long long res = 1; while (n > 0) { if (n & 1) res = res * a % mod; a = a * a % mod; n >>= 1; } return res; } long long modinv(long long a, long long mod) { return modpow(a, mod - 2, mod); } const ll MAX = 510000; ll fac[MAX], finv[MAX], inv[MAX]; void COMinit() { fac[0] = fac[1] = 1; finv[0] = finv[1] = 1; inv[1] = 1; for (ll i = 2; i < MAX; i++) { fac[i] = fac[i - 1] * i % MOD; inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD; finv[i] = finv[i - 1] * inv[i] % MOD; } } ll COM(ll n, ll k) { if (n < k) return 0; if (n < 0 || k < 0) return 0; return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD; } struct UnionFind { vector<int> par; UnionFind(int n) : par(n, -1) {} void init(int n) { par.assign(n, -1); } int root(int x) { if (par[x] < 0) return x; else return par[x] = root(par[x]); } bool issame(int x, int y) { return root(x) == root(y); } bool merge(int x, int y) { x = root(x); y = root(y); if (x == y) return false; if (par[x] > par[y]) swap(x, y); // merge technique par[x] += par[y]; par[y] = x; return true; } int size(int x) { return -par[root(x)]; } }; struct BIT { // 1-indexed!!! int n; vector<int> bit; BIT() { init(); } BIT(int n) : n(n) { init(); } void init() { bit.clear(); bit.resize(n + 1, 0); } int sum(int i) { int s = 0; while (i > 0) { s += bit[i]; i -= i & -i; } return s; } int sum(int x, int y) { return sum(y) - sum(x - 1); } void add(int i, int x) { while (i <= n) { bit[i] += x; i += i & -i; } } int lower_bound(int w) { if (w <= 0) return 0; int x = 0, r = 1; while (r < n) r <<= 1; for (int k = r; k > 0; k >>= 1) { if (x + k <= n && bit[x + k] < w) { w -= bit[x + k]; x += k; } } return x + 1; } }; struct LazySegmentTree { // private: ll n; vector<ll> node, lazy; // public: LazySegmentTree(vector<ll> v) { int sz = (int)v.size(); n = 1; while (n < sz) n *= 2; node.resize(2 * n - 1); lazy.resize(2 * n - 1, 0); for (int i = 0; i < sz; i++) node[i + n - 1] = v[i]; for (int i = n - 2; i >= 0; i--) node[i] = node[i * 2 + 1] + node[i * 2 + 2]; } void eval(int k, int l, int r) { if (lazy[k] != 0) { node[k] += lazy[k]; if (r - l > 1) { lazy[2 * k + 1] += lazy[k] / 2; lazy[2 * k + 2] += lazy[k] / 2; } lazy[k] = 0; } } void add(int a, int b, ll x, int k = 0, int l = 0, int r = -1) { if (r < 0) r = n; eval(k, l, r); if (b <= l || r <= a) return; if (a <= l && r <= b) { lazy[k] += (r - l) * x; eval(k, l, r); } else { add(a, b, x, 2 * k + 1, l, (l + r) / 2); add(a, b, x, 2 * k + 2, (l + r) / 2, r); node[k] = node[2 * k + 1] + node[2 * k + 2]; } } ll getsum(int a, int b, int k = 0, int l = 0, int r = -1) { if (r < 0) r = n; eval(k, l, r); if (b <= l || r <= a) return 0; if (a <= l && r <= b) return node[k]; ll vl = getsum(a, b, 2 * k + 1, l, (l + r) / 2); ll vr = getsum(a, b, 2 * k + 2, (l + r) / 2, r); return vl + vr; } }; ll digit_sum(ll v) { ll ret = 0; while (v) { ret += (v % 10); v /= 10; } return ret; } template <typename T> struct Kruskal { struct edge { ll from, to; T cost; ll used; edge() {} edge(ll from, ll to, T cost) : from(from), to(to), cost(cost), used(0) {} bool operator<(const edge &e) const { return cost < e.cost; } }; ll n; vector<ll> p, r; vector<edge> edges; Kruskal() {} Kruskal(ll n) : n(n) {} void init(ll n) { r.assign(n, 1); p.resize(n); iota(p.begin(), p.end(), 0); } ll find(ll x) { return (x == p[x] ? x : p[x] = find(p[x])); } bool same(ll x, ll y) { return find(x) == find(y); } void unite(ll x, ll y) { x = find(x); y = find(y); if (x == y) return; if (r[x] < r[y]) swap(x, y); r[x] += r[y]; p[y] = x; } void add_edge(ll u, ll v, T c) { edges.emplace_back(u, v, c); } T build() { sort(edges.begin(), edges.end()); init(n); T res = 0; for (auto &e : edges) { if (!same(e.from, e.to)) { res += e.cost; unite(e.from, e.to); e.used = 1; } } return res; } T build(ll k) { sort(edges.begin(), edges.end()); init(n); T res = 0; ll cnt = 0; for (auto &e : edges) { if (!same(e.from, e.to)) { res += e.cost; unite(e.from, e.to); e.used = 1; cnt++; } if (cnt == k) { break; } } return res; } }; int LIS(int a[], int n) { vector<int> A(n, 0x3f3f3f3f); for (int i = 0; i < n; i++) *lower_bound(A.begin(), A.end(), a[i]) = a[i]; return find(A.begin(), A.end(), 0x3f3f3f3f) - A.begin(); } // string maze[1010]; // //ll maze[100][100]; // ll grid_bfs(ll H, ll W, ll sx, ll sy, ll gx, ll gy) // { // //O(E) // int dx[4] = {1, 0, -1, 0}; // int dy[4] = {0, 1, 0, -1}; // vector<vector<ll>> dist(H, vector<ll>(W, -1)); // dist[sy][sx] = 0; // queue<PL> q; // q.push({sy, sx}); // while (!q.empty()) // { // ll x, y; // tie(y, x) = q.front(); // q.pop(); // if (y == gy && x == gx) // { // break; // } // for (int t = 0; t < 4; t++) // { // ll nx = x + dx[t], ny = y + dy[t]; // if (nx < 0 || ny < 0 || nx >= W || ny >= H || dist[ny][nx] != -1 // || maze[ny][nx] == '#') // { // continue; // } // dist[ny][nx] = dist[y][x] + 1; // q.push({ny, nx}); // } // } // return dist[gy][gx]; // } // no verify ll bfs(ll n, ll start, vector<vector<PL>> Edges) { vector<ll> dist(n + 1, -1); dist[start] = 0; queue<PL> q; q.push({start, 0}); while (!q.empty()) { ll node, cost; tie(cost, node) = q.front(); q.pop(); for (auto p : Edges[node]) { ll v = p.first, cost = p.second; if (dist[v] == -1) { dist[v] = dist[node] + cost; q.push({v, cost}); } } } } vector<vector<ll>> warshall_floyd(ll n, vector<vector<ll>> g, ll INF) { // init vector<vector<ll>> c(10,vector<ll>(10,0)); for (int k = 0; k < n; k++) { for (int i = 0; i < n; i++) { for (int j = 0; j < n; j++) { if (g[i][k] == INF || g[k][j] == INF) continue; g[i][j] = min(g[i][j], g[i][k] + g[k][j]); } } } return g; } struct Dijkstra { ll n; vector<vector<pair<ll, ll>>> Edges; vector<ll> Dist; vector<ll> Prev; vector<ll> PathNum; Dijkstra(ll n) : n(n), Edges(n), Dist(n), Prev(n), PathNum(n) { Prev.assign(n, -1); }; void add_edge(ll a, ll b, ll c, bool directed = true) { if (directed) { Edges[a].emplace_back(make_pair(b, c)); } else { Edges[a].emplace_back(make_pair(b, c)); Edges[b].emplace_back(make_pair(a, c)); } } // O((E+V)logV) void build(int start) { priority_queue<P, vector<P>, greater<P>> queue; fill(Dist.begin(), Dist.end(), 1e+18); // 1e18 !?!? fill(Prev.begin(), Prev.end(), -1); // 1e18 !?!? Dist[start] = 0; PathNum[start] = 1; queue.push(PL(0, start)); while (!queue.empty()) { PL p = queue.top(); queue.pop(); int v = p.second; if (Dist[v] < p.first) continue; for (int i = 0; i < Edges[v].size(); i++) { PL e = Edges[v][i]; if (Dist[e.first] > Dist[v] + e.second) { Dist[e.first] = Dist[v] + e.second; queue.push(P(Dist[e.first], e.first)); Prev[e.first] = v; PathNum[e.first] = PathNum[v]; } else if (Dist[e.first] == Dist[v] + e.second) { PathNum[e.first] += PathNum[v]; PathNum[e.first] %= MOD; } } } } ll dist(ll t) { return Dist[t]; } vector<ll> get_path(ll t) { vector<ll> path; for (; t != -1; t = Prev[t]) { path.push_back(t); } reverse(path.begin(), path.end()); return path; } ll get_path_num(ll t) { return PathNum[t]; } // int solve() // { // ll v, e, r; // cin >> v >> e >> r; // Dijkstra dij(v); // for (int i = 0; i < e; i++) // { // ll a, b, c; // cin >> a >> b >> c; // dij.add_edge(a, b, c); // } // dij.build(r); // for (int i = 0; i < v; i++) // { // if (dij.dist(i) == 1e18) // { // cout << "INF" << endl; // } // else // { // cout << dij.dist(i) << endl; // cout << dij.get_path(i) << endl; // cout << dij.get_path_num(i) << endl; // } // } // return 0; // } }; struct CumulativeSum2D { int H; int W; vector<vector<ll>> data; CumulativeSum2D(int H, int W) : H(H), W(W), data(H + 1, vector<ll>(W + 1, 0LL)) {} void add(int x, int y, ll z) { data[x + 1][y + 1] += z; } void build() { for (int i = 1; i < data.size(); i++) { for (int j = 1; j < data[i].size(); j++) { data[i][j] += data[i][j - 1] + data[i - 1][j] - data[i - 1][j - 1]; } } } void print() { for (int i = 0; i <= H; i++) { for (int j = 0; j <= W; j++) { cout << data[i][j] << " "; } cout << endl; } } ll query(int sx, int sy, int gx, int gy) { return (data[gy][gx] - data[sy - 1][gx] - data[gy][sx - 1] + data[sy - 1][sx - 1]); } }; struct LCA { int n, h; vector<vector<int>> par; vector<vector<pair<int, int>>> v; vector<ll> depth, dis; LCA(int sz) : n(sz), v(n), depth(n), dis(n) { h = 1; while ((1 << h) < n) h++; par.assign(h, vector<int>(n, -1)); } void add_edge(int x, int y, int z) { v[x].push_back({y, z}); v[y].push_back({x, z}); } void dfs(int x, int p, int d, ll di) { par[0][x] = p; depth[x] = d; dis[x] = di; for (auto to : v[x]) if (to.first != p) dfs(to.first, x, d + 1, di + to.second); } void build() { dfs(0, -1, 0, 0); for (int i = 0; i < h - 1; i++) { for (int j = 0; j < n; j++) { if (par[i][j] < 0) par[i + 1][j] = -1; else par[i + 1][j] = par[i][par[i][j]]; } } } int lca(int u, int v) { if (depth[u] > depth[v]) swap(u, v); for (int i = 0; i < h; i++) if ((depth[v] - depth[u]) >> i & 1) v = par[i][v]; if (u == v) return u; for (int i = h - 1; i >= 0; i--) { if (par[i][u] != par[i][v]) { u = par[i][u]; v = par[i][v]; } } return par[0][u]; } ll dist(int u, int v) { return dis[u] + dis[v] - 2 * dis[lca(u, v)]; } // int solve() // { // ll n; // cin >> n; // LCA lca(n); // for (int i = 0; i < n - 1; i++) // { // ll u, v, w; // cin >> u >> v >> w; // lca.add_edge(u, v, w); // } // lca.build(); // ll q; // cin >> q; // while (q--) // { // ll a, b, c; // cin >> a >> b >> c; // cout << (lca.dist(a, b) + lca.dist(b, c) + lca.dist(c, a)) / 2 << // endl; // } // return 0; // } }; vector<ll> compress(vector<ll> r) { // 1-indexed set<ll> se; for (int i = 0; i < r.size(); i++) { se.insert(r[i]); } map<ll, ll> m; ll cnt = 1; for (auto t : se) { m[t] = cnt; cnt++; } for (int i = 0; i < r.size(); i++) { r[i] = m[r[i]]; } return r; } template <class Abel> struct WeightedUnionFind { vector<int> par; vector<int> rank; vector<Abel> diff_weight; WeightedUnionFind(int n = 1, Abel SUM_UNITY = 0) { init(n, SUM_UNITY); } void init(int n = 1, Abel SUM_UNITY = 0) { par.resize(n); rank.resize(n); diff_weight.resize(n); for (int i = 0; i < n; ++i) par[i] = i, rank[i] = 0, diff_weight[i] = SUM_UNITY; } int root(int x) { if (par[x] == x) { return x; } else { int r = root(par[x]); diff_weight[x] += diff_weight[par[x]]; return par[x] = r; } } Abel weight(int x) { root(x); return diff_weight[x]; } bool issame(int x, int y) { return root(x) == root(y); } bool merge(int x, int y, Abel w) { w += weight(x); w -= weight(y); x = root(x); y = root(y); if (x == y) return false; if (rank[x] < rank[y]) swap(x, y), w = -w; if (rank[x] == rank[y]) ++rank[x]; par[y] = x; diff_weight[y] = w; return true; } Abel diff(int x, int y) { return weight(y) - weight(x); } }; void YES() { cout << "YES" << endl; exit(0); } void NO() { cout << "NO" << endl; exit(0); } void Yes() { cout << "Yes" << endl; exit(0); } void No() { cout << "No" << endl; exit(0); } void m1() { cout << -1 << endl; exit(0); } template <typename T> void out(const T t) { cout << t << '\n'; } template <typename T> void fout(const T t) { cout << fixed << setprecision(10) << t << '\n'; } /*------------------------------*/ void solve() { ll n; cin >> n; vector<ll> b(n); for (int i = 0; i < n; i++) { cin >> b[i]; } map<ll, ll> cnt; vector<ll> ans; for (int i = n; i >= 1; i--) { ll v = i; ll t = 0; while (v > n) { v += i; t += cnt[i]; } if (t % 2 != b[i - 1]) { ans.push_back(i); cnt[i]++; } } if (ans.size() == 0) { out(0); } else { out(ans.size()); cout << (ans[0]); for (int i = 1; i < ans.size(); i++) { cout << " " << ans[i]; } cout << endl; } } // g++.exe bbb.cpp -std=c++14 int main() { cout.precision(10); ios::sync_with_stdio(false); cin.tie(0); solve(); return 0; } // IMOSs//https://imoz.jp/algorithms/imos_method.html /*名前 accumulate(ALL(b),0LL) prev_permutation(ALL(v)) 辞書順で一個前の順列を構築する bitcount __builtin_popcountll 二次元累積和 CumulativeSum2D 10進数の桁和 digit_sum (b*b+c*c)**0.5 hypot cout << fixed << setprecision(10) << ans << endl; // 文字列t ->整数 atoi(t.c_str()); // 文字列t ->long long整数 stoll(t); ローカルではつかえない */ /* L=(1,0,1,1,3,4) C(1,3,0,1,1) 配列Lの中で x 以上 y 未満の値が何個あるのかが、累積和を使うとわかる。 具体的には C の累積和を S とすると、S[ y ] - S[ x ] で求められる */ /*実装例 zaatu sort(ALL(c)); c.erase(unique(ALL(c)), end(c)); ********** DP ********** ・ナップサックDP https://onlinejudge.u-aizu.ac.jp/courses/library/7/DPL/all/DPL_1_C 個数制限なしナップサック N<=100,W<=10000,v<=1000 https://onlinejudge.u-aizu.ac.jp/courses/library/7/DPL/all/DPL_1_B 01ナップサック N<=100,W<=10000,v<=1000 https://onlinejudge.u-aizu.ac.jp/courses/library/7/DPL/all/DPL_1_F 01ナップサック N<=100,W<=10^9,v<=100 https://onlinejudge.u-aizu.ac.jp/courses/library/7/DPL/1/DPL_1_H 巨大ナップザック N=40 w<10^15 , v<10^15 解)半分全列挙して、wi > wj かつvi < vj となるようなiを除いて、二分探索 ・部分文字列DP https://qiita.com/drken/items/a207e5ae3ea2cf17f4bd next[i][c] := S の i 文字目以降で最初に文字 c が登場する index https://www.hackerrank.com/contests/bbc003/challenges/bbc003-e/submissions/code/1321355726 (部分文字列の中で+の個数の偶奇によって、カウントするか決める) No.852 連続部分文字列 https://yukicoder.me/problems/no/852/editorial 連続な部分文字列における、文字の種類数の平均を求める 解)右端を固定すると dp[i+1] = dp[i] + (左にs[i]がでてきた位置との距離) E - Common Subsequence https://atcoder.jp/contests/abc130/tasks/abc130_e 文字列S、Tの共通整数列の数を求める 遷移はLCSのようにできるが、重複が発生するので除く必要がある ・桁DP 1 https://atcoder.jp/contests/abc029/tasks/abc029_d n以下の数字の中で現れた1の数を求める dp[i][j][k]:i桁目まで見たときに1の個数がk個の数字の個数 S - Digit Sum https://atcoder.jp/contests/dp/tasks/dp_s n以下の数字の中で、各桁の総和がDの倍数となるものを数える E - Almost Everywhere Zero https://atcoder.jp/contests/abc154/tasks/abc154_e n以下の数字の中で,0でない数字が丁度K個あるものの数を数える E - Sum Equals Xor https://atcoder.jp/contests/abc129/tasks/abc129_e a+b<=L,a+b=a^bとなる(a,b)を数える ************* 組み合わせ ************* https://codeforces.com/contest/888/problem/D 少なくともn-k個がpi=iとなるような順列の組の数え上げ →pi≠iとなる順列をモンモール数という。n-k~n個をpi=iと固定したときに、他の要素がpi≠iとなるような組み合わせの数(モンモール数)の積をとる https://codeforces.com/problemset/problem/322/B 赤・青・緑の花束が存在し、ある色を3本or全ての色を1本ずつ使ったときに、できる花束の最大数 https://atcoder.jp/contests/abc021/tasks/abc021_d https://codeforces.com/problemset/problem/1288/C 1 <=a1 <= a2 <= ... <= ak <= n となる(a1,a2..ak)の組の数 →等号がなければ単純にn個の要素の中からk個を選べばよい -> C(n,k) →等号がある場合は重複を許してk個選べばよい      -> H(n,k) http://codeforces.com/contest/1312/problem/D aj < aj+i < ... ai > ....ak > ak+1 かつ同じ数字のペアが一つだけ含まれるような組の数 D - Blue and Red Balls https://atcoder.jp/contests/abc132/tasks/abc132_d 青と赤のボールを並べ、連続している青を1~k個作ったときの並べ方の数 ************* 最短経路 ************* https://atcoder.jp/contests/joi2014yo/tasks/joi2014yo_e 移動できるノード数に制限がある場合の最短経路問題 →事前に幅優先探索でノード毎に移動できるノードを求めて、ダイクストラ ************* 遅延セグ木 ************* https://atcoder.jp/contests/abc153/submissions/10165699 *********** BIT *********** https://atcoder.jp/contests/abc157/tasks/abc157_e(アルファベット毎にBITもつやつ) https://hoj.hamako-ths.ed.jp/onlinejudge/problems/1276(中央値求めるやつ) *********** 数学 *********** 大きい数の約数 https://yukicoder.me/problems/no/677 10^nの全ての正の約数を列挙 →10^kは素因数として2^k,5^kしかもたないので、それぞれをかけ合わせる 例えば10は2^1*5*1なので、2^0,2^1に5^0,5^1をそれぞれかけ合わせればよい。 */
#include <algorithm> #include <cassert> #include <cmath> #include <cstdio> #include <cstdlib> #include <cstring> #include <functional> #include <iomanip> #include <iostream> #include <map> #include <numeric> #include <queue> #include <set> #include <string> #include <unordered_map> #include <unordered_set> #include <vector> using namespace std; typedef long long ll; typedef pair<ll, ll> P; typedef pair<ll, ll> PL; const ll mod = 1000000007; // const ll mod = 998244353; const ll MOD = 1000000007; const ll INF = 1LL << 60; #define PI (acos(-1)) #define ALL(c) (c).begin(), (c).end() #define en '\n' #define endl '\n' template <typename T> istream &operator>>(istream &is, vector<T> &vec) { for (auto &v : vec) is >> v; return is; } template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec) { os << "["; for (auto v : vec) os << v << ","; os << "]"; return os; } template <typename T> ostream &operator<<(ostream &os, const deque<T> &vec) { os << "deq["; for (auto v : vec) os << v << ","; os << "]"; return os; } template <typename T> ostream &operator<<(ostream &os, const set<T> &vec) { os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; } template <typename T> ostream &operator<<(ostream &os, const multiset<T> &vec) { os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; } template <typename T1, typename T2> ostream &operator<<(ostream &os, const pair<T1, T2> &pa) { os << "(" << pa.first << "," << pa.second << ")"; return os; } template <typename TK, typename TV> ostream &operator<<(ostream &os, const map<TK, TV> &mp) { os << "{"; for (auto v : mp) os << v.first << "=>" << v.second << ","; os << "}"; return os; } #define dbg(x) \ cerr << #x << " = " << (x) << " (L" << __LINE__ << ") " << __FILE__ << endl; // template <typename A, size_t N, typename T> template <typename T> inline string toString(const T &a) { ostringstream oss; oss << a; return oss.str(); }; template <int mod> struct ModInt { int x; ModInt() : x(0) {} ModInt(int64_t y) : x(y >= 0 ? y % mod : (mod - (-y) % mod) % mod) {} ModInt &operator+=(const ModInt &p) { if ((x += p.x) >= mod) x -= mod; return *this; } ModInt &operator-=(const ModInt &p) { if ((x += mod - p.x) >= mod) x -= mod; return *this; } ModInt &operator*=(const ModInt &p) { x = (int)(1LL * x * p.x % mod); return *this; } ModInt &operator/=(const ModInt &p) { *this *= p.inverse(); return *this; } ModInt operator-() const { return ModInt(-x); } ModInt operator+(const ModInt &p) const { return ModInt(*this) += p; } ModInt operator-(const ModInt &p) const { return ModInt(*this) -= p; } ModInt operator*(const ModInt &p) const { return ModInt(*this) *= p; } ModInt operator/(const ModInt &p) const { return ModInt(*this) /= p; } bool operator==(const ModInt &p) const { return x == p.x; } bool operator!=(const ModInt &p) const { return x != p.x; } ModInt inverse() const { int a = x, b = mod, u = 1, v = 0, t; while (b > 0) { t = a / b; swap(a -= t * b, b); swap(u -= t * v, v); } return ModInt(u); } ModInt pow(int64_t n) const { ModInt ret(1), mul(x); while (n > 0) { if (n & 1) ret *= mul; mul *= mul; n >>= 1; } return ret; } friend ostream &operator<<(ostream &os, const ModInt &p) { return os << p.x; } friend istream &operator>>(istream &is, ModInt &a) { int64_t t; is >> t; a = ModInt<mod>(t); return (is); } static int get_mod() { return mod; } }; using modint = ModInt<mod>; template <typename T> struct Combination { vector<T> _fact, _rfact, _inv; Combination(int sz) : _fact(sz + 1), _rfact(sz + 1), _inv(sz + 1) { _fact[0] = _rfact[sz] = _inv[0] = 1; for (int i = 1; i <= sz; i++) _fact[i] = _fact[i - 1] * i; _rfact[sz] /= _fact[sz]; for (int i = sz - 1; i >= 0; i--) _rfact[i] = _rfact[i + 1] * (i + 1); for (int i = 1; i <= sz; i++) _inv[i] = _rfact[i] * _fact[i - 1]; } inline T fact(int k) const { return _fact[k]; } inline T rfact(int k) const { return _rfact[k]; } inline T inv(int k) const { return _inv[k]; } T P(int n, int r) const { if (r < 0 || n < r) return 0; return fact(n) * rfact(n - r); } T C(int p, int q) const { if (q < 0 || p < q) return 0; return fact(p) * rfact(q) * rfact(p - q); } T H(int n, int r) const { if (n < 0 || r < 0) return (0); return r == 0 ? 1 : C(n + r - 1, r); } T NC(int p, int q) const { modint ret = 1; for (int i = 1; i <= q; i += 1) { ret = ret * p / i; p--; } return ret; } }; ll lcm(ll a, ll b) { return a / __gcd(a, b) * b; } bool is_prime(ll x) { if (x == 1) { return false; } for (ll i = 2; i * i <= x; i++) { if (x % i == 0) return false; } return true; } map<ll, int> prime_factor(ll n) { map<ll, int> ret; for (ll i = 2; i * i <= n; i++) { while (n % i == 0) { ret[i]++; n /= i; } } if (n != 1) ret[n] = 1; return ret; } vector<ll> divisor(ll n) { vector<ll> ret; for (ll i = 1; i * i <= n; i++) { if (n % i == 0) { ret.push_back(i); if (i * i != n) ret.push_back(n / i); } } sort(begin(ret), end(ret)); return (ret); } long long modpow(long long a, long long n, long long mod) { long long res = 1; while (n > 0) { if (n & 1) res = res * a % mod; a = a * a % mod; n >>= 1; } return res; } long long modinv(long long a, long long mod) { return modpow(a, mod - 2, mod); } const ll MAX = 510000; ll fac[MAX], finv[MAX], inv[MAX]; void COMinit() { fac[0] = fac[1] = 1; finv[0] = finv[1] = 1; inv[1] = 1; for (ll i = 2; i < MAX; i++) { fac[i] = fac[i - 1] * i % MOD; inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD; finv[i] = finv[i - 1] * inv[i] % MOD; } } ll COM(ll n, ll k) { if (n < k) return 0; if (n < 0 || k < 0) return 0; return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD; } struct UnionFind { vector<int> par; UnionFind(int n) : par(n, -1) {} void init(int n) { par.assign(n, -1); } int root(int x) { if (par[x] < 0) return x; else return par[x] = root(par[x]); } bool issame(int x, int y) { return root(x) == root(y); } bool merge(int x, int y) { x = root(x); y = root(y); if (x == y) return false; if (par[x] > par[y]) swap(x, y); // merge technique par[x] += par[y]; par[y] = x; return true; } int size(int x) { return -par[root(x)]; } }; struct BIT { // 1-indexed!!! int n; vector<int> bit; BIT() { init(); } BIT(int n) : n(n) { init(); } void init() { bit.clear(); bit.resize(n + 1, 0); } int sum(int i) { int s = 0; while (i > 0) { s += bit[i]; i -= i & -i; } return s; } int sum(int x, int y) { return sum(y) - sum(x - 1); } void add(int i, int x) { while (i <= n) { bit[i] += x; i += i & -i; } } int lower_bound(int w) { if (w <= 0) return 0; int x = 0, r = 1; while (r < n) r <<= 1; for (int k = r; k > 0; k >>= 1) { if (x + k <= n && bit[x + k] < w) { w -= bit[x + k]; x += k; } } return x + 1; } }; struct LazySegmentTree { // private: ll n; vector<ll> node, lazy; // public: LazySegmentTree(vector<ll> v) { int sz = (int)v.size(); n = 1; while (n < sz) n *= 2; node.resize(2 * n - 1); lazy.resize(2 * n - 1, 0); for (int i = 0; i < sz; i++) node[i + n - 1] = v[i]; for (int i = n - 2; i >= 0; i--) node[i] = node[i * 2 + 1] + node[i * 2 + 2]; } void eval(int k, int l, int r) { if (lazy[k] != 0) { node[k] += lazy[k]; if (r - l > 1) { lazy[2 * k + 1] += lazy[k] / 2; lazy[2 * k + 2] += lazy[k] / 2; } lazy[k] = 0; } } void add(int a, int b, ll x, int k = 0, int l = 0, int r = -1) { if (r < 0) r = n; eval(k, l, r); if (b <= l || r <= a) return; if (a <= l && r <= b) { lazy[k] += (r - l) * x; eval(k, l, r); } else { add(a, b, x, 2 * k + 1, l, (l + r) / 2); add(a, b, x, 2 * k + 2, (l + r) / 2, r); node[k] = node[2 * k + 1] + node[2 * k + 2]; } } ll getsum(int a, int b, int k = 0, int l = 0, int r = -1) { if (r < 0) r = n; eval(k, l, r); if (b <= l || r <= a) return 0; if (a <= l && r <= b) return node[k]; ll vl = getsum(a, b, 2 * k + 1, l, (l + r) / 2); ll vr = getsum(a, b, 2 * k + 2, (l + r) / 2, r); return vl + vr; } }; ll digit_sum(ll v) { ll ret = 0; while (v) { ret += (v % 10); v /= 10; } return ret; } template <typename T> struct Kruskal { struct edge { ll from, to; T cost; ll used; edge() {} edge(ll from, ll to, T cost) : from(from), to(to), cost(cost), used(0) {} bool operator<(const edge &e) const { return cost < e.cost; } }; ll n; vector<ll> p, r; vector<edge> edges; Kruskal() {} Kruskal(ll n) : n(n) {} void init(ll n) { r.assign(n, 1); p.resize(n); iota(p.begin(), p.end(), 0); } ll find(ll x) { return (x == p[x] ? x : p[x] = find(p[x])); } bool same(ll x, ll y) { return find(x) == find(y); } void unite(ll x, ll y) { x = find(x); y = find(y); if (x == y) return; if (r[x] < r[y]) swap(x, y); r[x] += r[y]; p[y] = x; } void add_edge(ll u, ll v, T c) { edges.emplace_back(u, v, c); } T build() { sort(edges.begin(), edges.end()); init(n); T res = 0; for (auto &e : edges) { if (!same(e.from, e.to)) { res += e.cost; unite(e.from, e.to); e.used = 1; } } return res; } T build(ll k) { sort(edges.begin(), edges.end()); init(n); T res = 0; ll cnt = 0; for (auto &e : edges) { if (!same(e.from, e.to)) { res += e.cost; unite(e.from, e.to); e.used = 1; cnt++; } if (cnt == k) { break; } } return res; } }; int LIS(int a[], int n) { vector<int> A(n, 0x3f3f3f3f); for (int i = 0; i < n; i++) *lower_bound(A.begin(), A.end(), a[i]) = a[i]; return find(A.begin(), A.end(), 0x3f3f3f3f) - A.begin(); } // string maze[1010]; // //ll maze[100][100]; // ll grid_bfs(ll H, ll W, ll sx, ll sy, ll gx, ll gy) // { // //O(E) // int dx[4] = {1, 0, -1, 0}; // int dy[4] = {0, 1, 0, -1}; // vector<vector<ll>> dist(H, vector<ll>(W, -1)); // dist[sy][sx] = 0; // queue<PL> q; // q.push({sy, sx}); // while (!q.empty()) // { // ll x, y; // tie(y, x) = q.front(); // q.pop(); // if (y == gy && x == gx) // { // break; // } // for (int t = 0; t < 4; t++) // { // ll nx = x + dx[t], ny = y + dy[t]; // if (nx < 0 || ny < 0 || nx >= W || ny >= H || dist[ny][nx] != -1 // || maze[ny][nx] == '#') // { // continue; // } // dist[ny][nx] = dist[y][x] + 1; // q.push({ny, nx}); // } // } // return dist[gy][gx]; // } // no verify ll bfs(ll n, ll start, vector<vector<PL>> Edges) { vector<ll> dist(n + 1, -1); dist[start] = 0; queue<PL> q; q.push({start, 0}); while (!q.empty()) { ll node, cost; tie(cost, node) = q.front(); q.pop(); for (auto p : Edges[node]) { ll v = p.first, cost = p.second; if (dist[v] == -1) { dist[v] = dist[node] + cost; q.push({v, cost}); } } } } vector<vector<ll>> warshall_floyd(ll n, vector<vector<ll>> g, ll INF) { // init vector<vector<ll>> c(10,vector<ll>(10,0)); for (int k = 0; k < n; k++) { for (int i = 0; i < n; i++) { for (int j = 0; j < n; j++) { if (g[i][k] == INF || g[k][j] == INF) continue; g[i][j] = min(g[i][j], g[i][k] + g[k][j]); } } } return g; } struct Dijkstra { ll n; vector<vector<pair<ll, ll>>> Edges; vector<ll> Dist; vector<ll> Prev; vector<ll> PathNum; Dijkstra(ll n) : n(n), Edges(n), Dist(n), Prev(n), PathNum(n) { Prev.assign(n, -1); }; void add_edge(ll a, ll b, ll c, bool directed = true) { if (directed) { Edges[a].emplace_back(make_pair(b, c)); } else { Edges[a].emplace_back(make_pair(b, c)); Edges[b].emplace_back(make_pair(a, c)); } } // O((E+V)logV) void build(int start) { priority_queue<P, vector<P>, greater<P>> queue; fill(Dist.begin(), Dist.end(), 1e+18); // 1e18 !?!? fill(Prev.begin(), Prev.end(), -1); // 1e18 !?!? Dist[start] = 0; PathNum[start] = 1; queue.push(PL(0, start)); while (!queue.empty()) { PL p = queue.top(); queue.pop(); int v = p.second; if (Dist[v] < p.first) continue; for (int i = 0; i < Edges[v].size(); i++) { PL e = Edges[v][i]; if (Dist[e.first] > Dist[v] + e.second) { Dist[e.first] = Dist[v] + e.second; queue.push(P(Dist[e.first], e.first)); Prev[e.first] = v; PathNum[e.first] = PathNum[v]; } else if (Dist[e.first] == Dist[v] + e.second) { PathNum[e.first] += PathNum[v]; PathNum[e.first] %= MOD; } } } } ll dist(ll t) { return Dist[t]; } vector<ll> get_path(ll t) { vector<ll> path; for (; t != -1; t = Prev[t]) { path.push_back(t); } reverse(path.begin(), path.end()); return path; } ll get_path_num(ll t) { return PathNum[t]; } // int solve() // { // ll v, e, r; // cin >> v >> e >> r; // Dijkstra dij(v); // for (int i = 0; i < e; i++) // { // ll a, b, c; // cin >> a >> b >> c; // dij.add_edge(a, b, c); // } // dij.build(r); // for (int i = 0; i < v; i++) // { // if (dij.dist(i) == 1e18) // { // cout << "INF" << endl; // } // else // { // cout << dij.dist(i) << endl; // cout << dij.get_path(i) << endl; // cout << dij.get_path_num(i) << endl; // } // } // return 0; // } }; struct CumulativeSum2D { int H; int W; vector<vector<ll>> data; CumulativeSum2D(int H, int W) : H(H), W(W), data(H + 1, vector<ll>(W + 1, 0LL)) {} void add(int x, int y, ll z) { data[x + 1][y + 1] += z; } void build() { for (int i = 1; i < data.size(); i++) { for (int j = 1; j < data[i].size(); j++) { data[i][j] += data[i][j - 1] + data[i - 1][j] - data[i - 1][j - 1]; } } } void print() { for (int i = 0; i <= H; i++) { for (int j = 0; j <= W; j++) { cout << data[i][j] << " "; } cout << endl; } } ll query(int sx, int sy, int gx, int gy) { return (data[gy][gx] - data[sy - 1][gx] - data[gy][sx - 1] + data[sy - 1][sx - 1]); } }; struct LCA { int n, h; vector<vector<int>> par; vector<vector<pair<int, int>>> v; vector<ll> depth, dis; LCA(int sz) : n(sz), v(n), depth(n), dis(n) { h = 1; while ((1 << h) < n) h++; par.assign(h, vector<int>(n, -1)); } void add_edge(int x, int y, int z) { v[x].push_back({y, z}); v[y].push_back({x, z}); } void dfs(int x, int p, int d, ll di) { par[0][x] = p; depth[x] = d; dis[x] = di; for (auto to : v[x]) if (to.first != p) dfs(to.first, x, d + 1, di + to.second); } void build() { dfs(0, -1, 0, 0); for (int i = 0; i < h - 1; i++) { for (int j = 0; j < n; j++) { if (par[i][j] < 0) par[i + 1][j] = -1; else par[i + 1][j] = par[i][par[i][j]]; } } } int lca(int u, int v) { if (depth[u] > depth[v]) swap(u, v); for (int i = 0; i < h; i++) if ((depth[v] - depth[u]) >> i & 1) v = par[i][v]; if (u == v) return u; for (int i = h - 1; i >= 0; i--) { if (par[i][u] != par[i][v]) { u = par[i][u]; v = par[i][v]; } } return par[0][u]; } ll dist(int u, int v) { return dis[u] + dis[v] - 2 * dis[lca(u, v)]; } // int solve() // { // ll n; // cin >> n; // LCA lca(n); // for (int i = 0; i < n - 1; i++) // { // ll u, v, w; // cin >> u >> v >> w; // lca.add_edge(u, v, w); // } // lca.build(); // ll q; // cin >> q; // while (q--) // { // ll a, b, c; // cin >> a >> b >> c; // cout << (lca.dist(a, b) + lca.dist(b, c) + lca.dist(c, a)) / 2 << // endl; // } // return 0; // } }; vector<ll> compress(vector<ll> r) { // 1-indexed set<ll> se; for (int i = 0; i < r.size(); i++) { se.insert(r[i]); } map<ll, ll> m; ll cnt = 1; for (auto t : se) { m[t] = cnt; cnt++; } for (int i = 0; i < r.size(); i++) { r[i] = m[r[i]]; } return r; } template <class Abel> struct WeightedUnionFind { vector<int> par; vector<int> rank; vector<Abel> diff_weight; WeightedUnionFind(int n = 1, Abel SUM_UNITY = 0) { init(n, SUM_UNITY); } void init(int n = 1, Abel SUM_UNITY = 0) { par.resize(n); rank.resize(n); diff_weight.resize(n); for (int i = 0; i < n; ++i) par[i] = i, rank[i] = 0, diff_weight[i] = SUM_UNITY; } int root(int x) { if (par[x] == x) { return x; } else { int r = root(par[x]); diff_weight[x] += diff_weight[par[x]]; return par[x] = r; } } Abel weight(int x) { root(x); return diff_weight[x]; } bool issame(int x, int y) { return root(x) == root(y); } bool merge(int x, int y, Abel w) { w += weight(x); w -= weight(y); x = root(x); y = root(y); if (x == y) return false; if (rank[x] < rank[y]) swap(x, y), w = -w; if (rank[x] == rank[y]) ++rank[x]; par[y] = x; diff_weight[y] = w; return true; } Abel diff(int x, int y) { return weight(y) - weight(x); } }; void YES() { cout << "YES" << endl; exit(0); } void NO() { cout << "NO" << endl; exit(0); } void Yes() { cout << "Yes" << endl; exit(0); } void No() { cout << "No" << endl; exit(0); } void m1() { cout << -1 << endl; exit(0); } template <typename T> void out(const T t) { cout << t << '\n'; } template <typename T> void fout(const T t) { cout << fixed << setprecision(10) << t << '\n'; } /*------------------------------*/ void solve() { ll n; cin >> n; vector<ll> b(n); for (int i = 0; i < n; i++) { cin >> b[i]; } map<ll, ll> cnt; vector<ll> ans; for (int i = n; i >= 1; i--) { ll v = i; ll t = 0; while (v <= n) { v += i; t += cnt[v]; } if (t % 2 != b[i - 1]) { ans.push_back(i); cnt[i]++; } } if (ans.size() == 0) { out(0); } else { out(ans.size()); cout << (ans[0]); for (int i = 1; i < ans.size(); i++) { cout << " " << ans[i]; } cout << endl; } } // g++.exe bbb.cpp -std=c++14 int main() { cout.precision(10); ios::sync_with_stdio(false); cin.tie(0); solve(); return 0; } // IMOSs//https://imoz.jp/algorithms/imos_method.html /*名前 accumulate(ALL(b),0LL) prev_permutation(ALL(v)) 辞書順で一個前の順列を構築する bitcount __builtin_popcountll 二次元累積和 CumulativeSum2D 10進数の桁和 digit_sum (b*b+c*c)**0.5 hypot cout << fixed << setprecision(10) << ans << endl; // 文字列t ->整数 atoi(t.c_str()); // 文字列t ->long long整数 stoll(t); ローカルではつかえない */ /* L=(1,0,1,1,3,4) C(1,3,0,1,1) 配列Lの中で x 以上 y 未満の値が何個あるのかが、累積和を使うとわかる。 具体的には C の累積和を S とすると、S[ y ] - S[ x ] で求められる */ /*実装例 zaatu sort(ALL(c)); c.erase(unique(ALL(c)), end(c)); ********** DP ********** ・ナップサックDP https://onlinejudge.u-aizu.ac.jp/courses/library/7/DPL/all/DPL_1_C 個数制限なしナップサック N<=100,W<=10000,v<=1000 https://onlinejudge.u-aizu.ac.jp/courses/library/7/DPL/all/DPL_1_B 01ナップサック N<=100,W<=10000,v<=1000 https://onlinejudge.u-aizu.ac.jp/courses/library/7/DPL/all/DPL_1_F 01ナップサック N<=100,W<=10^9,v<=100 https://onlinejudge.u-aizu.ac.jp/courses/library/7/DPL/1/DPL_1_H 巨大ナップザック N=40 w<10^15 , v<10^15 解)半分全列挙して、wi > wj かつvi < vj となるようなiを除いて、二分探索 ・部分文字列DP https://qiita.com/drken/items/a207e5ae3ea2cf17f4bd next[i][c] := S の i 文字目以降で最初に文字 c が登場する index https://www.hackerrank.com/contests/bbc003/challenges/bbc003-e/submissions/code/1321355726 (部分文字列の中で+の個数の偶奇によって、カウントするか決める) No.852 連続部分文字列 https://yukicoder.me/problems/no/852/editorial 連続な部分文字列における、文字の種類数の平均を求める 解)右端を固定すると dp[i+1] = dp[i] + (左にs[i]がでてきた位置との距離) E - Common Subsequence https://atcoder.jp/contests/abc130/tasks/abc130_e 文字列S、Tの共通整数列の数を求める 遷移はLCSのようにできるが、重複が発生するので除く必要がある ・桁DP 1 https://atcoder.jp/contests/abc029/tasks/abc029_d n以下の数字の中で現れた1の数を求める dp[i][j][k]:i桁目まで見たときに1の個数がk個の数字の個数 S - Digit Sum https://atcoder.jp/contests/dp/tasks/dp_s n以下の数字の中で、各桁の総和がDの倍数となるものを数える E - Almost Everywhere Zero https://atcoder.jp/contests/abc154/tasks/abc154_e n以下の数字の中で,0でない数字が丁度K個あるものの数を数える E - Sum Equals Xor https://atcoder.jp/contests/abc129/tasks/abc129_e a+b<=L,a+b=a^bとなる(a,b)を数える ************* 組み合わせ ************* https://codeforces.com/contest/888/problem/D 少なくともn-k個がpi=iとなるような順列の組の数え上げ →pi≠iとなる順列をモンモール数という。n-k~n個をpi=iと固定したときに、他の要素がpi≠iとなるような組み合わせの数(モンモール数)の積をとる https://codeforces.com/problemset/problem/322/B 赤・青・緑の花束が存在し、ある色を3本or全ての色を1本ずつ使ったときに、できる花束の最大数 https://atcoder.jp/contests/abc021/tasks/abc021_d https://codeforces.com/problemset/problem/1288/C 1 <=a1 <= a2 <= ... <= ak <= n となる(a1,a2..ak)の組の数 →等号がなければ単純にn個の要素の中からk個を選べばよい -> C(n,k) →等号がある場合は重複を許してk個選べばよい      -> H(n,k) http://codeforces.com/contest/1312/problem/D aj < aj+i < ... ai > ....ak > ak+1 かつ同じ数字のペアが一つだけ含まれるような組の数 D - Blue and Red Balls https://atcoder.jp/contests/abc132/tasks/abc132_d 青と赤のボールを並べ、連続している青を1~k個作ったときの並べ方の数 ************* 最短経路 ************* https://atcoder.jp/contests/joi2014yo/tasks/joi2014yo_e 移動できるノード数に制限がある場合の最短経路問題 →事前に幅優先探索でノード毎に移動できるノードを求めて、ダイクストラ ************* 遅延セグ木 ************* https://atcoder.jp/contests/abc153/submissions/10165699 *********** BIT *********** https://atcoder.jp/contests/abc157/tasks/abc157_e(アルファベット毎にBITもつやつ) https://hoj.hamako-ths.ed.jp/onlinejudge/problems/1276(中央値求めるやつ) *********** 数学 *********** 大きい数の約数 https://yukicoder.me/problems/no/677 10^nの全ての正の約数を列挙 →10^kは素因数として2^k,5^kしかもたないので、それぞれをかけ合わせる 例えば10は2^1*5*1なので、2^0,2^1に5^0,5^1をそれぞれかけ合わせればよい。 */
[ "expression.operator.compare.change", "control_flow.loop.condition.change", "assignment.value.change", "identifier.change", "variable_access.subscript.index.change" ]
778,078
778,077
u644778646
cpp
p02972
#include <algorithm> #include <cassert> #include <cmath> #include <cstdio> #include <cstdlib> #include <cstring> #include <functional> #include <iostream> #include <map> #include <queue> #include <set> #include <string> #include <vector> using namespace std; typedef long long ll; int a[1000100]; int z[1000100]; int main() { int N; cin >> N; for (int i = 1; i < N + 1; i++) cin >> a[i]; for (int i = N; i > 0; i--) { int c = 0; for (int j = i * 2; j < N + 1; j += 2) { c += z[j]; } if (c % 2 != a[i]) z[i] = 1; } int M = 0; vector<int> ans; for (int i = 1; i < N + 1; i++) { if (z[i]) { M++; ans.push_back(i); } } cout << M << endl; if (M == 0) return 0; for (int i = 0; i < M - 1; i++) { cout << ans[i] << " "; } cout << ans[M - 1] << endl; }
#include <algorithm> #include <cassert> #include <cmath> #include <cstdio> #include <cstdlib> #include <cstring> #include <functional> #include <iostream> #include <map> #include <queue> #include <set> #include <string> #include <vector> using namespace std; typedef long long ll; int a[1000100]; int z[1000100]; int main() { int N; cin >> N; for (int i = 1; i < N + 1; i++) cin >> a[i]; for (int i = N; i > 0; i--) { int c = 0; for (int j = i * 2; j < N + 1; j += i) { c += z[j]; } if (c % 2 != a[i]) z[i] = 1; } int M = 0; vector<int> ans; for (int i = 1; i < N + 1; i++) { if (z[i]) { M++; ans.push_back(i); } } cout << M << endl; if (M == 0) return 0; for (int i = 0; i < M - 1; i++) { cout << ans[i] << " "; } cout << ans[M - 1] << endl; }
[ "assignment.value.change", "identifier.replace.add", "literal.replace.remove" ]
778,079
778,080
u644778646
cpp
p02972
#include <algorithm> #include <cassert> #include <cmath> #include <cstdio> #include <cstdlib> #include <cstring> #include <functional> #include <iostream> #include <map> #include <queue> #include <set> #include <string> #include <vector> using namespace std; typedef long long ll; int a[1000100]; int z[1000100]; int main() { int N; cin >> N; for (int i = 1; i < N + 1; i++) cin >> a[i]; for (int i = N; i > 0; i--) { int c = 0; for (int j = i * 2; j < N + 1; j *= 2) { c += z[j]; } if (c % 2 != a[i]) z[i] = 1; } int M = 0; vector<int> ans; for (int i = 1; i < N + 1; i++) { if (z[i]) { M++; ans.push_back(i); } } cout << M << endl; if (M == 0) return 0; for (int i = 0; i < M - 1; i++) { cout << ans[i] << " "; } cout << ans[M - 1] << endl; }
#include <algorithm> #include <cassert> #include <cmath> #include <cstdio> #include <cstdlib> #include <cstring> #include <functional> #include <iostream> #include <map> #include <queue> #include <set> #include <string> #include <vector> using namespace std; typedef long long ll; int a[1000100]; int z[1000100]; int main() { int N; cin >> N; for (int i = 1; i < N + 1; i++) cin >> a[i]; for (int i = N; i > 0; i--) { int c = 0; for (int j = i * 2; j < N + 1; j += i) { c += z[j]; } if (c % 2 != a[i]) z[i] = 1; } int M = 0; vector<int> ans; for (int i = 1; i < N + 1; i++) { if (z[i]) { M++; ans.push_back(i); } } cout << M << endl; if (M == 0) return 0; for (int i = 0; i < M - 1; i++) { cout << ans[i] << " "; } cout << ans[M - 1] << endl; }
[ "control_flow.loop.for.update.change", "assignment.change" ]
778,081
778,080
u644778646
cpp
p02972
#include <algorithm> #include <cassert> #include <cmath> #include <cstdio> #include <cstdlib> #include <cstring> #include <functional> #include <iostream> #include <map> #include <queue> #include <set> #include <string> #include <vector> using namespace std; typedef long long ll; int a[1000100]; int z[1000100]; int main() { int N; cin >> N; for (int i = 1; i < N + 1; i++) cin >> a[i]; for (int i = N; i > 0; i--) { int c = 0; for (int j = i; j < N + 1; j *= 2) { c += z[j]; } if (c % 2 != a[i]) z[i] = 1; } int M = 0; vector<int> ans; for (int i = 1; i < N + 1; i++) { if (z[i]) { M++; ans.push_back(i); } } cout << M << endl; if (M == 0) return 0; for (int i = 0; i < M - 1; i++) { cout << ans[i] << " "; } cout << ans[M - 1] << endl; }
#include <algorithm> #include <cassert> #include <cmath> #include <cstdio> #include <cstdlib> #include <cstring> #include <functional> #include <iostream> #include <map> #include <queue> #include <set> #include <string> #include <vector> using namespace std; typedef long long ll; int a[1000100]; int z[1000100]; int main() { int N; cin >> N; for (int i = 1; i < N + 1; i++) cin >> a[i]; for (int i = N; i > 0; i--) { int c = 0; for (int j = i * 2; j < N + 1; j += i) { c += z[j]; } if (c % 2 != a[i]) z[i] = 1; } int M = 0; vector<int> ans; for (int i = 1; i < N + 1; i++) { if (z[i]) { M++; ans.push_back(i); } } cout << M << endl; if (M == 0) return 0; for (int i = 0; i < M - 1; i++) { cout << ans[i] << " "; } cout << ans[M - 1] << endl; }
[ "control_flow.loop.for.initializer.change", "control_flow.loop.for.update.change", "assignment.change" ]
778,082
778,080
u644778646
cpp
p02972
#include <algorithm> #include <cassert> #include <cmath> #include <cstdio> #include <cstdlib> #include <cstring> #include <functional> #include <iostream> #include <map> #include <queue> #include <set> #include <string> #include <vector> using namespace std; typedef long long ll; int a[100010]; int z[100010]; int main() { int N; cin >> N; for (int i = 1; i < N + 1; i++) cin >> a[i]; for (int i = N; i > 0; i--) { int c = 0; for (int j = i; j < N + 1; j *= 2) { c += z[j]; } if (c % 2 != a[i]) z[i] = 1; } int M = 0; vector<int> ans; for (int i = 1; i < N + 1; i++) { if (z[i]) { M++; ans.push_back(i); } } cout << M << endl; if (M == 0) return 0; for (int i = 0; i < M - 1; i++) { cout << ans[i] << " "; } cout << ans[M - 1] << endl; }
#include <algorithm> #include <cassert> #include <cmath> #include <cstdio> #include <cstdlib> #include <cstring> #include <functional> #include <iostream> #include <map> #include <queue> #include <set> #include <string> #include <vector> using namespace std; typedef long long ll; int a[1000100]; int z[1000100]; int main() { int N; cin >> N; for (int i = 1; i < N + 1; i++) cin >> a[i]; for (int i = N; i > 0; i--) { int c = 0; for (int j = i * 2; j < N + 1; j += i) { c += z[j]; } if (c % 2 != a[i]) z[i] = 1; } int M = 0; vector<int> ans; for (int i = 1; i < N + 1; i++) { if (z[i]) { M++; ans.push_back(i); } } cout << M << endl; if (M == 0) return 0; for (int i = 0; i < M - 1; i++) { cout << ans[i] << " "; } cout << ans[M - 1] << endl; }
[ "literal.number.change", "variable_declaration.array_dimensions.change", "control_flow.loop.for.initializer.change", "control_flow.loop.for.update.change", "assignment.change" ]
778,083
778,080
u644778646
cpp
p02972
#include <bits/stdc++.h> typedef long long ll; #define rep(i, n) for (ll i = 0; i < (n); i++) #define repr(i, n) for (ll i = (n - 1); i >= 0; i--) #define pb push_back #define mp make_pair #define all(x) x.begin(), x.end() #define br cout << "\n"; using namespace std; const int INF = 1e9; const int MOD = 1e9 + 7; using Graph = vector<vector<ll>>; template <class T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; } template <class T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; } // 0 false, 1 true // string to int : -48 // ceil(a) 1.2->2.0 // c++17 g++ -std=c++17 a.cpp int main() { std::cout << std::fixed << std::setprecision(15); ll n; cin >> n; vector<long long> vec(n + 1); rep(i, n) cin >> vec[i + 1]; vector<ll> ans(n + 1); vector<ll> res; for (ll i = n; i >= 1; i--) { ll sum = 0; for (ll j = i; j <= n; j += i) { sum += vec[j]; } if (sum % 2 == 0) { ans[i] = 0; } else { ans[i] = 1; res.push_back(i); } } /* for(ll i = 1; i <= n; i++){ cout << ans[i] << " "; } cout << endl; */ cout << res.size() << endl; rep(i, res.size()) { cout << res[i] << " "; } cout << endl; }
#include <bits/stdc++.h> typedef long long ll; #define rep(i, n) for (ll i = 0; i < (n); i++) #define repr(i, n) for (ll i = (n - 1); i >= 0; i--) #define pb push_back #define mp make_pair #define all(x) x.begin(), x.end() #define br cout << "\n"; using namespace std; const int INF = 1e9; const int MOD = 1e9 + 7; using Graph = vector<vector<ll>>; template <class T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; } template <class T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; } // 0 false, 1 true // string to int : -48 // ceil(a) 1.2->2.0 // c++17 g++ -std=c++17 a.cpp int main() { std::cout << std::fixed << std::setprecision(15); ll n; cin >> n; vector<long long> vec(n + 1); rep(i, n) cin >> vec[i + 1]; vector<ll> ans(n + 1); vector<ll> res; for (ll i = n; i >= 1; i--) { ll sum = 0; for (ll j = i; j <= n; j += i) { sum += ans[j]; } // cout << "i = " << i << " sum = " << sum << endl; if (sum % 2 == vec[i]) { ans[i] = 0; } else { ans[i] = 1; res.push_back(i); } } /* for(ll i = 1; i <= n; i++){ cout << ans[i] << " "; } cout << endl; */ cout << res.size() << endl; rep(i, res.size()) { cout << res[i] << " "; } cout << endl; }
[ "assignment.value.change", "identifier.change", "identifier.replace.add", "literal.replace.remove", "control_flow.branch.if.condition.change", "control_flow.loop.for.condition.change" ]
778,084
778,085
u799939777
cpp
p02972
#include <bits/stdc++.h> using namespace std; #define MOD 1000000007 typedef long long ll; typedef pair<int, int> P; int a[200000] = {}, res[200000] = {}; int main() { int n, tem, i, j, m = 0; cin >> n; for (i = 0; i < n; i++) { cin >> a[i]; } for (i = n; i > 0; i--) { j = 2; tem = 0; while (j * i < n) { tem += res[j * i - 1]; tem %= 2; j++; } res[i - 1] = tem ^ a[i - 1]; m += res[i - 1]; } cout << m << "\n"; for (i = 0; i < n; i++) { if (res[i]) { cout << i + 1 << " "; } } return 0; }
#include <bits/stdc++.h> using namespace std; #define MOD 1000000007 typedef long long ll; typedef pair<int, int> P; int a[200000] = {}, res[200000] = {}; int main() { int n, tem, i, j, m = 0; cin >> n; for (i = 0; i < n; i++) { cin >> a[i]; } for (i = n; i > 0; i--) { j = 2; tem = 0; while (j * i <= n) { tem += res[j * i - 1]; tem %= 2; j++; } res[i - 1] = tem ^ a[i - 1]; m += res[i - 1]; } cout << m << "\n"; for (i = 0; i < n; i++) { if (res[i]) { cout << i + 1 << " "; } } return 0; }
[ "expression.operator.compare.change", "control_flow.loop.condition.change" ]
778,086
778,087
u058348416
cpp
p02972
#include <bits/stdc++.h> using namespace std; #define MOD 1000000007 typedef long long ll; typedef pair<int, int> P; int a[200000] = {}, res[200000] = {}; int main() { int n, tem, i, j, m = 0; cin >> n; for (i = 0; i < n; i++) { cin >> a[i]; } for (i = n; i > 0; i--) { j = 2; tem = 0; while (j * i < n) { tem += a[j * i - 1]; tem %= 2; j++; } res[i - 1] = tem ^ a[i - 1]; m += res[i - 1]; } cout << m << "\n"; for (i = 0; i < n; i++) { if (res[i]) { cout << i + 1 << " "; } } return 0; }
#include <bits/stdc++.h> using namespace std; #define MOD 1000000007 typedef long long ll; typedef pair<int, int> P; int a[200000] = {}, res[200000] = {}; int main() { int n, tem, i, j, m = 0; cin >> n; for (i = 0; i < n; i++) { cin >> a[i]; } for (i = n; i > 0; i--) { j = 2; tem = 0; while (j * i <= n) { tem += res[j * i - 1]; tem %= 2; j++; } res[i - 1] = tem ^ a[i - 1]; m += res[i - 1]; } cout << m << "\n"; for (i = 0; i < n; i++) { if (res[i]) { cout << i + 1 << " "; } } return 0; }
[ "expression.operator.compare.change", "control_flow.loop.condition.change", "assignment.value.change", "identifier.change" ]
778,088
778,087
u058348416
cpp
p02972
#include <bits/stdc++.h> using namespace std; #define MOD 1000000007 typedef long long ll; typedef pair<int, int> P; int a[200000] = {}, res[200000] = {}; int main() { int n, tem, i, j, m = 0; cin >> n; for (i = 0; i < n; i++) { cin >> a[i]; } for (i = n; i > 0; i--) { j = 2; tem = 0; while (j * i < n) { tem += a[j * i - 1]; tem %= 2; j++; } res[i - 1] = tem ^ a[i - 1]; m += res[i - 1]; } cout << m << "\n"; for (i = 0; i < n; i++) { if (res[i]) { cout << i + 1 << "\n"; } } return 0; }
#include <bits/stdc++.h> using namespace std; #define MOD 1000000007 typedef long long ll; typedef pair<int, int> P; int a[200000] = {}, res[200000] = {}; int main() { int n, tem, i, j, m = 0; cin >> n; for (i = 0; i < n; i++) { cin >> a[i]; } for (i = n; i > 0; i--) { j = 2; tem = 0; while (j * i <= n) { tem += res[j * i - 1]; tem %= 2; j++; } res[i - 1] = tem ^ a[i - 1]; m += res[i - 1]; } cout << m << "\n"; for (i = 0; i < n; i++) { if (res[i]) { cout << i + 1 << " "; } } return 0; }
[ "expression.operator.compare.change", "control_flow.loop.condition.change", "assignment.value.change", "identifier.change", "literal.string.change", "io.output.change" ]
778,089
778,087
u058348416
cpp
p02972
#include <bits/stdc++.h> using namespace std; #define MOD 1000000007 typedef long long ll; typedef pair<int, int> P; int a[200000] = {}, res[200000] = {}; int main() { int n, tem, i, j, m = 0; cin >> n; for (i = 0; i < n; i++) { cin >> a[i]; } for (i = n; i > 0; i--) { j = 2; tem = 0; while (j * i < n) { tem += a[j * i]; tem %= 2; j++; } res[i - 1] = tem ^ a[i - 1]; m += res[i - 1]; } cout << m << "\n"; for (i = 0; i < n; i++) { if (res[i]) { cout << i + 1 << " "; } } return 0; }
#include <bits/stdc++.h> using namespace std; #define MOD 1000000007 typedef long long ll; typedef pair<int, int> P; int a[200000] = {}, res[200000] = {}; int main() { int n, tem, i, j, m = 0; cin >> n; for (i = 0; i < n; i++) { cin >> a[i]; } for (i = n; i > 0; i--) { j = 2; tem = 0; while (j * i <= n) { tem += res[j * i - 1]; tem %= 2; j++; } res[i - 1] = tem ^ a[i - 1]; m += res[i - 1]; } cout << m << "\n"; for (i = 0; i < n; i++) { if (res[i]) { cout << i + 1 << " "; } } return 0; }
[ "expression.operator.compare.change", "control_flow.loop.condition.change", "assignment.value.change", "identifier.change", "assignment.change" ]
778,090
778,087
u058348416
cpp
p02972
#include <algorithm> #include <iostream> #include <vector> using namespace std; #ifdef _MSC_VER int debug = 1; #else int debug = 0; #endif int main() { int n; cin >> n; auto a = vector<int>(n + 5); for (int i = 1; i <= n; i++) cin >> a[i]; auto balls_in = vector<int>(n + 5); for (int i = n; i >= 1; i--) { auto sum = 0; for (int j = i + i; j <= n; j *= 2) sum += balls_in[j]; if (sum % 2 != a[i]) { balls_in[i] = 1; } } cout << count(balls_in.begin(), balls_in.end(), 1) << "\n"; for (int i = 1; i <= n; i++) { if (balls_in[i]) { cout << i << "\n"; } } return 0; }
#include <algorithm> #include <iostream> #include <vector> using namespace std; #ifdef _MSC_VER int debug = 1; #else int debug = 0; #endif int main() { int n; cin >> n; auto a = vector<int>(n + 5); for (int i = 1; i <= n; i++) cin >> a[i]; auto balls_in = vector<int>(n + 5); for (int i = n; i >= 1; i--) { auto sum = 0; for (int j = i + i; j <= n; j += i) sum += balls_in[j]; if (sum % 2 != a[i]) { balls_in[i] = 1; } } cout << count(balls_in.begin(), balls_in.end(), 1) << "\n"; for (int i = 1; i <= n; i++) { if (balls_in[i]) { cout << i << "\n"; } } return 0; }
[ "control_flow.loop.for.update.change", "assignment.change" ]
778,098
778,099
u723394740
cpp
p02972
#include <algorithm> #include <iostream> #include <vector> using namespace std; #ifdef _MSC_VER int debug = 1; #else int debug = 0; #endif int main() { int n; cin >> n; auto a = vector<int>(n + 5); for (int i = 1; i <= n; i++) cin >> a[i]; auto balls_in = vector<int>(n + 5); for (int i = n; i >= 1; i--) { auto sum = 0; for (int j = i + i; j <= n; j++) sum += balls_in[j]; if (sum % 2 != a[i]) { balls_in[i] = 1; } } cout << count(balls_in.begin(), balls_in.end(), 1) << "\n"; for (int i = 1; i <= n; i++) { if (balls_in[i]) { cout << i << "\n"; } } return 0; }
#include <algorithm> #include <iostream> #include <vector> using namespace std; #ifdef _MSC_VER int debug = 1; #else int debug = 0; #endif int main() { int n; cin >> n; auto a = vector<int>(n + 5); for (int i = 1; i <= n; i++) cin >> a[i]; auto balls_in = vector<int>(n + 5); for (int i = n; i >= 1; i--) { auto sum = 0; for (int j = i + i; j <= n; j += i) sum += balls_in[j]; if (sum % 2 != a[i]) { balls_in[i] = 1; } } cout << count(balls_in.begin(), balls_in.end(), 1) << "\n"; for (int i = 1; i <= n; i++) { if (balls_in[i]) { cout << i << "\n"; } } return 0; }
[]
778,100
778,099
u723394740
cpp
p02972
#include <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < (int)(n); i++) using namespace std; int main() { int n; cin >> n; vector<int> a(n); rep(i, n) cin >> a[i]; vector<int> ans(n, 0); for (int i = n / 2; i < n; i++) { ans[i] = a[i]; } for (int i = (n / 2 - 1); i >= 0; i--) { int sum = 0; for (int j = 2; j * (i + 1) <= n; j++) { sum += a[(i + 1) * j - 1]; } ans[i] = abs(sum % 2 - a[i]); } vector<int> ans_; int ct = 0; rep(i, n) { if (ans[i] == 1) { ct++; ans_.push_back(i + 1); } } cout << ct << endl; rep(i, ans_.size()) cout << ans_[i] << endl; return 0; }
#include <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < (int)(n); i++) using namespace std; int main() { int n; cin >> n; vector<int> a(n); rep(i, n) cin >> a[i]; vector<int> ans(n, 0); for (int i = n / 2; i < n; i++) { ans[i] = a[i]; } for (int i = (n / 2 - 1); i >= 0; i--) { int sum = 0; for (int j = 2; j * (i + 1) <= n; j++) { sum += ans[(i + 1) * j - 1]; } ans[i] = abs(sum % 2 - a[i]); } vector<int> ans_; int ct = 0; rep(i, n) { if (ans[i] == 1) { ct++; ans_.push_back(i + 1); } } cout << ct << endl; rep(i, ans_.size()) cout << ans_[i] << endl; return 0; }
[ "assignment.value.change", "identifier.change" ]
778,103
778,104
u697968316
cpp
p02972
#include <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < (int)(n); i++) using namespace std; int main() { int n; cin >> n; vector<int> a(n); rep(i, n) cin >> a[i]; vector<int> ans(n, 0); for (int i = n / 2; i < n; i++) { ans[i] = a[i]; } for (int i = (n / 2 - 1); i >= 0; i--) { int sum = 0; for (int j = 2; j * (i + 1) <= n; j++) { sum += a[(i + 1) * j - 1]; } ans[i] = abs(sum % 2 - a[i]); } vector<int> ans_; int ct = 0; rep(i, n) { if (ans[i] == 1) { ct++; ans_.push_back(i + 1); } } cout << ct << endl; rep(i, ans_.size()) cout << ans_[i] << endl; }
#include <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < (int)(n); i++) using namespace std; int main() { int n; cin >> n; vector<int> a(n); rep(i, n) cin >> a[i]; vector<int> ans(n, 0); for (int i = n / 2; i < n; i++) { ans[i] = a[i]; } for (int i = (n / 2 - 1); i >= 0; i--) { int sum = 0; for (int j = 2; j * (i + 1) <= n; j++) { sum += ans[(i + 1) * j - 1]; } ans[i] = abs(sum % 2 - a[i]); } vector<int> ans_; int ct = 0; rep(i, n) { if (ans[i] == 1) { ct++; ans_.push_back(i + 1); } } cout << ct << endl; rep(i, ans_.size()) cout << ans_[i] << endl; return 0; }
[ "assignment.value.change", "identifier.change", "control_flow.return.add", "control_flow.return.0.add" ]
778,105
778,104
u697968316
cpp
p02972
#include <bits/stdc++.h> using namespace std; #define REP(i, start, count) for (int i = (start); i < (int)(count); ++i) #define rep(i, count) REP(i, 0, count) #define ALLOF(c) (c).begin(), (c).end() typedef long long ll; typedef unsigned long long ull; int main(void) { int N; cin >> N; vector<int> a(N + 1); REP(i, 1, N + 1) cin >> a[i]; vector<int> ans(N + 1); int M = 0; for (int i = N; i >= 1; --i) { int k = i + i; int odd = 0; while (k <= N) { odd = (odd + ans[k]) % 2; k += i; } if (a[i] != odd) { ans[i] = 1; M++; } } cout << M << endl; rep(i, N) { if (ans[i] == 1) { cout << i; if (i != N - 1) cout << " "; } } cout << endl; return 0; }
#include <bits/stdc++.h> using namespace std; #define REP(i, start, count) for (int i = (start); i < (int)(count); ++i) #define rep(i, count) REP(i, 0, count) #define ALLOF(c) (c).begin(), (c).end() typedef long long ll; typedef unsigned long long ull; int main(void) { int N; cin >> N; vector<int> a(N + 1); REP(i, 1, N + 1) cin >> a[i]; vector<int> ans(N + 1); int M = 0; for (int i = N; i >= 1; --i) { int k = i + i; int odd = 0; while (k <= N) { odd = (odd + ans[k]) % 2; k += i; } if (a[i] != odd) { ans[i] = 1; M++; } } cout << M << endl; rep(i, N + 1) { if (ans[i] == 1) { cout << i; if (i != N) cout << " "; } } cout << endl; return 0; }
[ "expression.operation.binary.remove" ]
778,109
778,108
u159231764
cpp
p02972
#include <bits/stdc++.h> using namespace std; typedef long long ll; const ll mod = 1e9 + 7; const ll INF = mod * mod; #define rep(i, n) for (ll i = 0; i < (ll)(n); i++) #define all(x) (x).begin(), (x).end() ll min(ll a, ll b) { if (a > b) { return b; } else { return a; } } ll max(ll a, ll b) { if (a > b) { return a; } else { return b; } } ll power(ll a, ll b) { ll ans = 1; for (ll i = 1; i <= b; i++) { ans *= a; } return ans; } ll gcd(ll m, ll n) { if (n == 0) { return m; } return gcd(n, m % n); } ll lcm(ll a, ll b) { ll g = gcd(a, b); return a / gcd(a, b) * b; } int main() { ll N; cin >> N; vector<ll> a(N); ll sum = 0; rep(i, N) { cin >> a[i]; } vector<bool> ans(N); ll num = 0; for (ll i = N - 1; i >= 0; i--) { if (i == N - 1) { if (a[i] == 1) { ans[i] = true; num++; } else { ans[i] = false; } } else { ll sum = 0; ll X = N / (i + 1) - 1; for (ll j = 1; j <= X; j++) { if (ans[j * (i + 1)]) { sum++; } } if ((sum % 2 == 1 && a[i] == 0) || (sum % 2 == 0 && a[i] == 1)) { ans[i] = true; num++; } else { ans[i] = false; } } } cout << num << endl; rep(i, N) { if (ans[i]) { cout << i + 1 << " "; } } cout << endl; }
#include <bits/stdc++.h> using namespace std; typedef long long ll; const ll mod = 1e9 + 7; const ll INF = mod * mod; #define rep(i, n) for (ll i = 0; i < (ll)(n); i++) #define all(x) (x).begin(), (x).end() ll min(ll a, ll b) { if (a > b) { return b; } else { return a; } } ll max(ll a, ll b) { if (a > b) { return a; } else { return b; } } ll power(ll a, ll b) { ll ans = 1; for (ll i = 1; i <= b; i++) { ans *= a; } return ans; } ll gcd(ll m, ll n) { if (n == 0) { return m; } return gcd(n, m % n); } ll lcm(ll a, ll b) { ll g = gcd(a, b); return a / gcd(a, b) * b; } int main() { ll N; cin >> N; vector<ll> a(N); ll sum = 0; rep(i, N) { cin >> a[i]; } vector<bool> ans(N); ll num = 0; for (ll i = N - 1; i >= 0; i--) { if (i == N - 1) { if (a[i] == 1) { ans[i] = true; num++; } else { ans[i] = false; } } else { ll sum = 0; ll X = N / (i + 1); for (ll j = 2; j <= X; j++) { if (ans[j * (i + 1) - 1]) { sum++; } } if ((sum % 2 == 1 && a[i] == 0) || (sum % 2 == 0 && a[i] == 1)) { ans[i] = true; num++; } else { ans[i] = false; } } } cout << num << endl; rep(i, N) { if (ans[i]) { cout << i + 1 << " "; } } cout << endl; }
[ "expression.operation.binary.remove", "literal.number.change", "variable_declaration.value.change", "control_flow.loop.for.initializer.change", "expression.off_by_one", "control_flow.branch.if.condition.change", "control_flow.loop.for.condition.change", "misc.off_by_one" ]
778,112
778,113
u096717230
cpp
p02972
//#include "stdafx.h" #include <algorithm> #include <climits> #include <cmath> #include <cstring> #include <functional> #include <iomanip> #include <iostream> #include <map> #include <math.h> #include <numeric> #include <queue> #include <set> #include <sstream> #include <stack> #include <string> #include <tuple> #include <vector> /*-----------------------------------------------------------------------------  パラメータ定義 -------------------------------------------------------------------------------*/ #define N_MAX (200 * 1000) #define K_MAX (10) #define M_MAX (10) #define H_MAX (1000) #define W_MAX (1000) using namespace std; /*-----------------------------------------------------------------------------  メモ -------------------------------------------------------------------------------*/ #if 0 vector<vector<vector<SDWORD>>> XXX(AAA, vector<vector<SDWORD>>(BBBB, vector<SDWORD>(CCC, -1))); auto position = lower_bound(getValue.begin(), getValue.end(), 0); // 0以上の要素位置を探す auto position = upper_bound(getValue.begin(), getValue.end(), 0); // 0より大きいの要素位置を探す int idx_lower = distance(getValue.begin(), position); // 0以上の要素インデックス int eraseNum = MIN(idx_lower, delCnt); // 要素位置が個数になる priority_queue<int, std::vector<int>, greater<int>> que; #endif /*-----------------------------------------------------------------------------  定義 -------------------------------------------------------------------------------*/ #define REP(i, n) for (int(i) = 0; (i) < (int)(n); ++(i)) #define REPN(i, m, n) for (int(i) = m; (i) < (int)(n); ++(i)) #define INF 2e9 #define MOD (1000 * 1000 * 1000 + 7) #define Ceil(x, n) (((((DWORD)(x)) + ((n)-1)) / n)) /* Nの倍数に切り上げ */ #define CeilN(x, n) (((((DWORD)(x)) + ((n)-1)) / n) * n) /* Nの倍数に切り上げ \ */ #define FloorN(x, n) ((x) - (x) % (n)) /* Nの倍数に切り下げ */ #define IsOdd(x) (((x)&0x01UL) == 0x01UL) #define IsEven(x) (!IsOdd((x))) #define BitSetV(Val, Bit) ((Val) |= (Bit)) #define BitTstV(Val, Bit) ((Val) & (Bit)) #define ArrayLength(x) (sizeof(x) / sizeof(x[0])) #define MAX_DWORD (0xFFFFFFFF) #define MAX_SDWORD ((SDWORD)0x7FFFFFFF) #define MIN_SDWORD ((SDWORD)0x80000000) #define MAX_QWORD ((QWORD)0xFFFFFFFFFFFFFFFF) #define MIN_QWORD ((QWORD)0x0000000000000000) #define MAX_SQWORD ((SQWORD)0x7FFFFFFFFFFFFFFF) #define MIN_SQWORD ((SQWORD)0x8000000000000000) #define M_PI 3.14159265358979323846 #define deg_to_rad(deg) (((deg) / 180) * M_PI) #define rad_to_deg(rad) ((rad * 180) / M_PI) #define prique(T) priority_queue<T, vector<T>, greater<T>> typedef long SDWORD; typedef long long SQWORD; typedef unsigned long DWORD; typedef unsigned long long int QWORD; typedef pair<int, int> P; /*-----------------------------------------------------------------------------  自作ライブラリ -------------------------------------------------------------------------------*/ /* 最大公約数 */ QWORD gcd(QWORD a, QWORD b) { if (b == 0) return a; return gcd(b, a % b); } /* 最小公倍数 */ QWORD lcm(QWORD a, QWORD b) { return a * b / gcd(a, b); } /* 素数判定 */ bool pri(QWORD p) { for (QWORD i = 2; i * i <= p; ++i) if (p % i == 0) return false; return p > 1; } typedef struct edge { DWORD to; QWORD cost; edge() : to(0), cost(0) {} edge(DWORD argTo, QWORD argCost) : to(argTo), cost(argCost) {} bool operator>(const edge &e) const { return cost > e.cost; } } EDGE; /*-----------------------------------------------------------------------------  処理 -------------------------------------------------------------------------------*/ int main() { int N; cin >> N; vector<int> a(N + 1); REP(i, N) cin >> a[i + 1]; vector<int> res(N + 1, 0); for (int i = N; i >= 1; i--) { int nowCnt = 0; for (int j = (i + i); j <= N; j += i) { if (res[j]) { nowCnt++; } } if ((nowCnt % 2) == 0) { if (a[i]) { res[i] = 1; } } else { if (!a[i]) { res[i] = 1; } } } int ans = 0; REPN(i, 1, N + 1) if (res[i]) ans++; cout << ans << endl; REPN(i, 1, N + 1) if (res[i]) cout << res[i] << ' '; cout << endl; return 0; }
//#include "stdafx.h" #include <algorithm> #include <climits> #include <cmath> #include <cstring> #include <functional> #include <iomanip> #include <iostream> #include <map> #include <math.h> #include <numeric> #include <queue> #include <set> #include <sstream> #include <stack> #include <string> #include <tuple> #include <vector> /*-----------------------------------------------------------------------------  パラメータ定義 -------------------------------------------------------------------------------*/ #define N_MAX (200 * 1000) #define K_MAX (10) #define M_MAX (10) #define H_MAX (1000) #define W_MAX (1000) using namespace std; /*-----------------------------------------------------------------------------  メモ -------------------------------------------------------------------------------*/ #if 0 vector<vector<vector<SDWORD>>> XXX(AAA, vector<vector<SDWORD>>(BBBB, vector<SDWORD>(CCC, -1))); auto position = lower_bound(getValue.begin(), getValue.end(), 0); // 0以上の要素位置を探す auto position = upper_bound(getValue.begin(), getValue.end(), 0); // 0より大きいの要素位置を探す int idx_lower = distance(getValue.begin(), position); // 0以上の要素インデックス int eraseNum = MIN(idx_lower, delCnt); // 要素位置が個数になる priority_queue<int, std::vector<int>, greater<int>> que; #endif /*-----------------------------------------------------------------------------  定義 -------------------------------------------------------------------------------*/ #define REP(i, n) for (int(i) = 0; (i) < (int)(n); ++(i)) #define REPN(i, m, n) for (int(i) = m; (i) < (int)(n); ++(i)) #define INF 2e9 #define MOD (1000 * 1000 * 1000 + 7) #define Ceil(x, n) (((((DWORD)(x)) + ((n)-1)) / n)) /* Nの倍数に切り上げ */ #define CeilN(x, n) (((((DWORD)(x)) + ((n)-1)) / n) * n) /* Nの倍数に切り上げ \ */ #define FloorN(x, n) ((x) - (x) % (n)) /* Nの倍数に切り下げ */ #define IsOdd(x) (((x)&0x01UL) == 0x01UL) #define IsEven(x) (!IsOdd((x))) #define BitSetV(Val, Bit) ((Val) |= (Bit)) #define BitTstV(Val, Bit) ((Val) & (Bit)) #define ArrayLength(x) (sizeof(x) / sizeof(x[0])) #define MAX_DWORD (0xFFFFFFFF) #define MAX_SDWORD ((SDWORD)0x7FFFFFFF) #define MIN_SDWORD ((SDWORD)0x80000000) #define MAX_QWORD ((QWORD)0xFFFFFFFFFFFFFFFF) #define MIN_QWORD ((QWORD)0x0000000000000000) #define MAX_SQWORD ((SQWORD)0x7FFFFFFFFFFFFFFF) #define MIN_SQWORD ((SQWORD)0x8000000000000000) #define M_PI 3.14159265358979323846 #define deg_to_rad(deg) (((deg) / 180) * M_PI) #define rad_to_deg(rad) ((rad * 180) / M_PI) #define prique(T) priority_queue<T, vector<T>, greater<T>> typedef long SDWORD; typedef long long SQWORD; typedef unsigned long DWORD; typedef unsigned long long int QWORD; typedef pair<int, int> P; /*-----------------------------------------------------------------------------  自作ライブラリ -------------------------------------------------------------------------------*/ /* 最大公約数 */ QWORD gcd(QWORD a, QWORD b) { if (b == 0) return a; return gcd(b, a % b); } /* 最小公倍数 */ QWORD lcm(QWORD a, QWORD b) { return a * b / gcd(a, b); } /* 素数判定 */ bool pri(QWORD p) { for (QWORD i = 2; i * i <= p; ++i) if (p % i == 0) return false; return p > 1; } typedef struct edge { DWORD to; QWORD cost; edge() : to(0), cost(0) {} edge(DWORD argTo, QWORD argCost) : to(argTo), cost(argCost) {} bool operator>(const edge &e) const { return cost > e.cost; } } EDGE; /*-----------------------------------------------------------------------------  処理 -------------------------------------------------------------------------------*/ int main() { int N; cin >> N; vector<int> a(N + 1); REP(i, N) cin >> a[i + 1]; vector<int> res(N + 1, 0); for (int i = N; i >= 1; i--) { int nowCnt = 0; for (int j = (i + i); j <= N; j += i) { if (res[j]) { nowCnt++; } } if ((nowCnt % 2) == 0) { if (a[i]) { res[i] = 1; } } else { if (!a[i]) { res[i] = 1; } } } int ans = 0; REPN(i, 1, N + 1) if (res[i]) ans++; cout << ans << endl; REPN(i, 1, N + 1) if (res[i]) cout << i << ' '; cout << endl; return 0; }
[]
778,144
778,145
u796408111
cpp
p02972
#include <cmath> #include <iostream> #include <set> #include <vector> using namespace std; int main() { int n; cin >> n; vector<int> v(n + 1); for (int i = 0; i <= n; ++i) { cin >> v[i + 1]; } vector<set<int>> measure(n + 1); for (int i = 1; i <= sqrt(n); ++i) { for (int j = 1; i * j <= n; ++j) { measure[i].insert(j); measure[j].insert(i); } } vector<int> ans; vector<int> memo(n + 1); int cnt = 0; for (int i = n; i > 0; --i) { if ((v[i] % 2) != (memo[i] % 2)) { ans.push_back(i); ++cnt; for (int idx : measure[i]) { memo[idx] += 1; } } } cout << ans.size() << endl; bool first = true; for (int num : ans) { if (!first) { cout << " "; } else { first = false; } cout << num; } cout << endl; }
#include <cmath> #include <iostream> #include <set> #include <vector> using namespace std; int main() { int n; cin >> n; vector<int> v(n + 1); for (int i = 0; i <= n; ++i) { cin >> v[i + 1]; } vector<set<int>> measure(n + 1); for (int i = 1; i <= sqrt(n); ++i) { for (int j = 1; i * j <= n; ++j) { measure[i * j].insert(j); measure[i * j].insert(i); } } vector<int> ans; vector<int> memo(n + 1); int cnt = 0; for (int i = n; i > 0; --i) { if ((v[i] % 2) != (memo[i] % 2)) { ans.push_back(i); ++cnt; for (int idx : measure[i]) { memo[idx] += 1; } } } cout << ans.size() << endl; bool first = true; for (int num : ans) { if (!first) { cout << " "; } else { first = false; } cout << num; } cout << endl; }
[ "expression.operation.binary.add" ]
778,146
778,147
u469612749
cpp
p02972
#include <bits/stdc++.h> #define rep(i, a, n) for (ll i = a; i < n; i++) #define per(i, a, n) for (ll i = n - 1; i >= a; i--) #define fill0(n) setfill('0') << right << setw(n) #define all(x) (x).begin(), (x).end() #define rall(x) (x).rbegin(), (x).rend() #define LONGMAX 1e18 #define intMAX 1000000000 using namespace std; typedef long long ll; typedef pair<ll, ll> P; const ll mod = 1e9 + 7; int n; int main() { cin >> n; vector<int> a(n + 1); for (int i = 1; i < n + 1; i++) cin >> a[i]; vector<int> b(n + 1); //答えが入る配列 for (int i = n; i >= 1; i--) { int sum = 0; // iの倍数 //でかい方からやって,n/2まではとりあえず実行しない for (int j = i + i; j <= n; j += i) { sum ^= b[j]; } b[i] = sum ^ a[i]; } vector<int> ans; for (int i = 0; i < n; i++) { if (b[i] == 1) ans.push_back(i); } cout << ans.size() << endl; for (int i = 0; i < ans.size(); i++) { cout << ans[i] << " "; } cout << endl; return 0; }
#include <bits/stdc++.h> #define rep(i, a, n) for (ll i = a; i < n; i++) #define per(i, a, n) for (ll i = n - 1; i >= a; i--) #define fill0(n) setfill('0') << right << setw(n) #define all(x) (x).begin(), (x).end() #define rall(x) (x).rbegin(), (x).rend() #define LONGMAX 1e18 #define intMAX 1000000000 using namespace std; typedef long long ll; typedef pair<ll, ll> P; const ll mod = 1e9 + 7; int n; int main() { cin >> n; vector<int> a(n + 1); for (int i = 1; i < n + 1; i++) cin >> a[i]; vector<int> b(n + 1); //答えが入る配列 for (int i = n; i >= 1; i--) { int sum = 0; // iの倍数 //でかい方からやって,n/2まではとりあえず実行しない for (int j = i + i; j <= n; j += i) { sum ^= b[j]; } b[i] = sum ^ a[i]; } vector<int> ans; for (int i = 1; i < n + 1; i++) { if (b[i] == 1) ans.push_back(i); } cout << ans.size() << endl; for (int i = 0; i < ans.size(); i++) { cout << ans[i] << " "; } cout << endl; return 0; }
[ "literal.number.change", "variable_declaration.value.change", "control_flow.loop.for.initializer.change", "expression.off_by_one", "control_flow.loop.for.condition.change", "misc.off_by_one" ]
778,153
778,154
u255001744
cpp
p02972
#include <algorithm> #include <cmath> #include <cstdio> #include <cstdlib> #include <deque> #include <functional> #include <iostream> #include <map> #include <numeric> #include <queue> #include <set> #include <stack> #include <vector> #define Rep(i, n) for (int i = 0; i < n; ++i) #define rep(i, n) for (int i = 1; i <= n; ++i) #define ll long long #define INF 100000000 #define mod 1000000007 #define PI 3.14159265359 #define All(a) (a).begin(), (a).end() using namespace std; using P = pair<ll int, ll int>; int dx[4] = {0, 1, 0, -1}; int dy[4] = {1, 0, -1, 0}; template <class T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; } template <class T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; } int N; int a[210000]; int res[210000]; int main() { cin >> N; rep(i, N) cin >> a[i]; for (int k = N; k >= 1; --k) { int tmp = 0; for (int i = (k * 2); i <= N; i += k) { tmp += res[i]; } tmp = tmp % 2; if (a[k] == tmp) { res[k] = 0; } else { res[k] = 1; } } vector<int> ans; rep(i, N) { if (res[i] == 1) { ans.push_back(res[i]); } } cout << ans.size() << "\n"; if (ans.size() > 0) { Rep(i, ans.size() - 1) { cout << ans[i] << " "; } cout << ans[ans.size() - 1] << "\n"; } }
#include <algorithm> #include <cmath> #include <cstdio> #include <cstdlib> #include <deque> #include <functional> #include <iostream> #include <map> #include <numeric> #include <queue> #include <set> #include <stack> #include <vector> #define Rep(i, n) for (int i = 0; i < n; ++i) #define rep(i, n) for (int i = 1; i <= n; ++i) #define ll long long #define INF 100000000 #define mod 1000000007 #define PI 3.14159265359 #define All(a) (a).begin(), (a).end() using namespace std; using P = pair<ll int, ll int>; int dx[4] = {0, 1, 0, -1}; int dy[4] = {1, 0, -1, 0}; template <class T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; } template <class T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; } int N; int a[210000]; int res[210000]; int main() { cin >> N; rep(i, N) cin >> a[i]; for (int k = N; k >= 1; --k) { int tmp = 0; for (int i = (k * 2); i <= N; i += k) { tmp += res[i]; } tmp = tmp % 2; if (a[k] == tmp) { res[k] = 0; } else { res[k] = 1; } } vector<int> ans; rep(i, N) { if (res[i] == 1) { ans.push_back(i); } } cout << ans.size() << "\n"; if (ans.size() > 0) { Rep(i, ans.size() - 1) { cout << ans[i] << " "; } cout << ans[ans.size() - 1] << "\n"; } }
[ "call.arguments.change" ]
778,163
778,164
u337199858
cpp
p02972
#include <bits/stdc++.h> #define mod 1000000007 #define rep(i, n) for (int i = 0; i < n; ++i) using namespace std; typedef long long ll; const long long INF = 1LL << 60; int main(void) { int N; cin >> N; vector<int> a(N + 1); rep(i, N) cin >> a[i + 1]; int ans = 0; vector<int> b(N + 1); for (int i = N; i > 0; i--) { int count = 0; for (int j = i; j <= N; j += i) count += a[j]; if (count % 2 == a[i]) b[i] = 0; else b[i] = 1; ans += b[i]; } cout << ans << endl; rep(i, N) if (b[i + 1] == 1) cout << i + 1 << " "; return 0; }
#include <bits/stdc++.h> #define mod 1000000007 #define rep(i, n) for (int i = 0; i < n; ++i) using namespace std; typedef long long ll; const long long INF = 1LL << 60; int main(void) { int N; cin >> N; vector<int> a(N + 1); rep(i, N) cin >> a[i + 1]; int ans = 0; vector<int> b(N + 1, 0); for (int i = N; i > 0; i--) { int count = 0; for (int j = i; j <= N; j += i) count += b[j]; if (count % 2 == a[i]) b[i] = 0; else b[i] = 1; ans += b[i]; } cout << ans << endl; rep(i, N) if (b[i + 1] == 1) cout << i + 1 << " "; return 0; }
[ "call.arguments.add", "assignment.value.change", "identifier.change" ]
778,165
778,166
u895536055
cpp
p02972
// D-Preparing Boxes // https://atcoder.jp/contests/abc134/tasks/abc134_d?lang=ja #include <bits/stdc++.h> using namespace std; typedef long long ll; #define MAX 200000 + 4 ll n; int a[MAX]; int main() { scanf("%lld", &n); for (ll i = 0; i < n; i++) scanf("%d", &a[i + 1]); ll m = 0; vector<int> b(n + 1, 0); for (ll i = n; i >= 1; i--) { ll s = 0; for (ll j = i * 2; j <= n; j += j) { s ^= b[j]; } b[i] = s ^ a[i]; } vector<int> ans; for (int i = 1; i <= n; i++) { if (b[i] != 0) ans.push_back(i); } printf("%ld\n", ans.size()); for (ll i = 0; i < ans.size(); i++) printf("%d ", ans[i]); printf("\n"); }
// D-Preparing Boxes // https://atcoder.jp/contests/abc134/tasks/abc134_d?lang=ja #include <bits/stdc++.h> using namespace std; typedef long long ll; #define MAX 200000 + 4 ll n; int a[MAX]; int main() { scanf("%lld", &n); for (ll i = 0; i < n; i++) scanf("%d", &a[i + 1]); ll m = 0; vector<int> b(n + 1, 0); for (ll i = n; i >= 1; i--) { ll s = 0; for (ll j = i * 2; j <= n; j += i) { s ^= b[j]; } b[i] = s ^ a[i]; } vector<int> ans; for (int i = 1; i <= n; i++) { if (b[i] != 0) ans.push_back(i); } printf("%ld\n", ans.size()); for (ll i = 0; i < ans.size(); i++) printf("%d ", ans[i]); printf("\n"); }
[ "assignment.value.change", "identifier.change" ]
778,169
778,170
u586577600
cpp
p02972
#include <bits/stdc++.h> #define ll long long #define ld long double #define mk make_pair #define fi first #define se second #define vll vector<ll> #define pii pair<ll, ll> #define vvll vector<vector<ll>> #define pb push_back #define sz(v) (v).size() #define inf 1e18 #define md 1000000007 #define all(v) (v).begin(), (v).end() #define rep(i, a, b) for (ll i = a; i < b; ++i) #define tel(a) \ { cout << a << "\n"; } #define tell(a, b) \ { cout << a << " | " << b << "\n"; } #define telll(a, b, c) \ { cout << a << " | " << b << " | " << c << "\n"; } #define teln(v, n) \ { \ cout << "v- "; \ rep(i, 0, n) cout << v[i] << " "; \ cout << "\n"; \ } #define IOS \ ios_base::sync_with_stdio(false); \ cin.tie(0); \ cout.tie(0); using namespace std; #define M 1000010 int main() { IOS; ll n; cin >> n; ll a[n + 1]; rep(i, 1, n + 1) cin >> a[i]; ll b[n + 1]; rep(i, 1, n + 1) b[i] = 0; vll v; for (int i = n; i > 0; --i) { ll x = a[i], cnt = 0; for (int j = i; j <= n; j += i) cnt += b[j]; if (a[i] % 2) b[i] = 1, v.pb(i); } sort(all(v)); cout << sz(v) << "\n"; rep(i, 0, sz(v)) cout << v[i] << " "; return 0; }
#include <bits/stdc++.h> #define ll long long #define ld long double #define mk make_pair #define fi first #define se second #define vll vector<ll> #define pii pair<ll, ll> #define vvll vector<vector<ll>> #define pb push_back #define sz(v) (v).size() #define inf 1e18 #define md 1000000007 #define all(v) (v).begin(), (v).end() #define rep(i, a, b) for (ll i = a; i < b; ++i) #define tel(a) \ { cout << a << "\n"; } #define tell(a, b) \ { cout << a << " | " << b << "\n"; } #define telll(a, b, c) \ { cout << a << " | " << b << " | " << c << "\n"; } #define teln(v, n) \ { \ cout << "v- "; \ rep(i, 0, n) cout << v[i] << " "; \ cout << "\n"; \ } #define IOS \ ios_base::sync_with_stdio(false); \ cin.tie(0); \ cout.tie(0); using namespace std; #define M 1000010 int main() { IOS; ll n; cin >> n; ll a[n + 1]; rep(i, 1, n + 1) cin >> a[i]; ll b[n + 1]; rep(i, 1, n + 1) b[i] = 0; vll v; for (int i = n; i > 0; --i) { ll x = a[i], cnt = 0; for (int j = i; j <= n; j += i) cnt += b[j]; if (x % 2 != cnt % 2) b[i] = 1, v.pb(i); } sort(all(v)); cout << sz(v) << "\n"; rep(i, 0, sz(v)) cout << v[i] << " "; return 0; }
[ "control_flow.loop.for.condition.change", "control_flow.branch.if.condition.change" ]
778,171
778,172
u742553775
cpp
p02972
#include <algorithm> #include <iostream> #include <queue> #include <stack> #include <string> #include <unordered_map> #include <unordered_set> #include <vector> using namespace std; typedef long long ll; typedef vector<int> VI; typedef pair<ll, ll> P; #define rep(a, n) for (int a = 0; a < n; a++) int main(void) { int n; cin >> n; vector<ll> as(n + 1, 0); vector<ll> bs(n + 1, 0); vector<ll> ms; rep(i, n) { cin >> as[i + 1]; bs[i + 1] = 0; } for (int i = n; i > 0; i--) { ll sum = 0; for (int j = i * 2; j <= n; j += i) { sum += bs[j]; } bs[i] = ((sum - as[i]) % 2 == 0) ? 0 : 1; if (bs[i]) ms.push_back(as[i]); } cout << ms.size() << endl; for (auto e : ms) { cout << e << " "; } cout << endl; return 0; }
#include <algorithm> #include <iostream> #include <queue> #include <stack> #include <string> #include <unordered_map> #include <unordered_set> #include <vector> using namespace std; typedef long long ll; typedef vector<int> VI; typedef pair<ll, ll> P; #define rep(a, n) for (int a = 0; a < n; a++) int main(void) { int n; cin >> n; vector<ll> as(n + 1, 0); vector<ll> bs(n + 1, 0); vector<ll> ms; rep(i, n) { cin >> as[i + 1]; bs[i + 1] = 0; } for (int i = n; i > 0; i--) { ll sum = 0; for (int j = i * 2; j <= n; j += i) { sum += bs[j]; } bs[i] = ((sum - as[i]) % 2 == 0) ? 0 : 1; if (bs[i]) ms.push_back(i); } cout << ms.size() << endl; for (auto e : ms) { cout << e << " "; } cout << endl; return 0; }
[ "call.arguments.change" ]
778,173
778,174
u834771741
cpp
p02972
#define _CRT_SECURE_NO_WARNINGS #include <algorithm> #include <cmath> #include <cstdio> #include <string> using namespace std; #define N_MAX 200010 int main() { FILE *fin = NULL, *fout = NULL; // fin = freopen("input.txt", "r", stdin); // fout = freopen("output.txt", "w", stdout); int N; scanf("%d", &N); int a[N_MAX]; for (int i = 0; i < N; i++) { scanf("%d", a + i + 1); } int b[N_MAX], cnt = 0; for (int i = N; i >= 1; i--) { int sum = 0; for (int j = i * 2; j <= N; j += i) { sum += a[j]; } if ((sum % 2) == a[i]) { b[i] = 0; } else { b[i] = 1; cnt++; } } printf("%d\n", cnt); for (int i = 1; i <= N; i++) { if (1 == b[i]) { printf("%d ", i); } } // finalize if (NULL != fin) fclose(fin); if (NULL != fout) fclose(fout); return 0; }
#define _CRT_SECURE_NO_WARNINGS #include <algorithm> #include <cmath> #include <cstdio> #include <string> using namespace std; #define N_MAX 200010 int main() { FILE *fin = NULL, *fout = NULL; // fin = freopen("input.txt", "r", stdin); // fout = freopen("output.txt", "w", stdout); int N; scanf("%d", &N); int a[N_MAX]; for (int i = 0; i < N; i++) { scanf("%d", a + i + 1); } int b[N_MAX], cnt = 0; for (int i = N; i >= 1; i--) { int sum = 0; for (int j = i * 2; j <= N; j += i) { sum += b[j]; } if ((sum % 2) == a[i]) { b[i] = 0; } else { b[i] = 1; cnt++; } } printf("%d\n", cnt); for (int i = 1; i <= N; i++) { if (1 == b[i]) { printf("%d ", i); } } // finalize if (NULL != fin) fclose(fin); if (NULL != fout) fclose(fout); return 0; }
[ "assignment.value.change", "identifier.change" ]
778,192
778,193
u103357948
cpp
p02972
/* ** Vishal Raj Roy ** Indian Institute of Technology Kharagpur */ #include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> using namespace std; using namespace __gnu_pbds; #define pb push_back #define eb emplace_back #define mp make_pair #define mt make_tuple #define lb lower_bound #define ub upper_bound #define all(x) x.begin(), x.end() #define at(X, N) get<N>(X) #define xx first #define yy second #define sz(x) ((int)x.size()) #define nl cout << "\n"; // FOR(i,1,10) gives 1,2,3,....,9 and FOR(i,10,1) gives 9,8,....,1 also FOR(it, // end(v), begin(v)) and FOR(it, begin(v), end(v)) #define FOR(i, begin, end) \ for (__typeof(end) i = (begin) - ((begin) > (end)); \ i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end))) #define SEL(X, C) for (auto &X : C) #define ima INT_MAX #define imi INT_MIN #define lma LLONG_MAX #define lmi LLONG_MIN #define name(X) (#X) #define tl(args...) \ { \ string _s = #args; \ replace(_s.begin(), _s.end(), ',', ' '); \ stringstream _ss(_s); \ istream_iterator<string> _it(_ss); \ tell(_it, args); \ } #define tk(args...) take(args); void tell(istream_iterator<string> it) {} template <typename T, typename... Args> void tell(istream_iterator<string> it, T a, Args... args) { cout << *it << " = " << a << "\n"; tell(++it, args...); } void take() {} template <typename T, typename... Args> void take(T &a, Args &...args) { cin >> a; take(args...); } template <class T> struct custom_hash { static uint64_t splitmix64(uint64_t x) { x += 0x9e3779b97f4a7c15; x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9; x = (x ^ (x >> 27)) * 0x94d049bb133111eb; return x ^ (x >> 31); } T operator()(uint64_t x) const { static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count(); return splitmix64(x + FIXED_RANDOM); } T operator()(tuple<uint64_t, uint64_t> x) const { static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count(); return splitmix64(get<0>(x) + FIXED_RANDOM) ^ (splitmix64(get<1>(x) + FIXED_RANDOM) >> 1); } }; // T operator()(pair<uint64_t,uint64_t> x) const { static const uint64_t // FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count(); // return splitmix64(x.first + FIXED_RANDOM)^(splitmix64(x.second + // FIXED_RANDOM) >> 1); } }; template <class L, class R> ostream &operator<<(ostream &os, pair<L, R> P) { return os << "(" << P.xx << "," << P.yy << ")"; } template <class L, class R> ostream &operator<<(ostream &os, tuple<L, R> P) { return os << "(" << get<0>(P) << "," << get<1>(P) << ")"; } template <class L, class R, class S> ostream &operator<<(ostream &os, tuple<L, R, S> P) { return os << "(" << get<0>(P) << "," << get<1>(P) << "," << get<2>(P) << ")"; } template <class T, class A> ostream &operator<<(ostream &os, vector<T, A> V) { os /*<< name(V)<< " is "*/ << "\n"; FOR(i, 0, sz(V)) os << " " << name(V) << "[" << i << "] = " << V[i] << "\n"; return os; /*<<"\n";*/ } template <class T, class H, class P, class A> ostream &operator<<(ostream &os, unordered_set<T, H, P, A> S) { os /*name(S) << " is"*/ << " ["; int i = 0; for (auto ELE : S) { os << ELE; if (i < sz(S) - 1) os << ", "; i++; } return os << "]"; /*<<"\n"; */ } template <class S, class T, class H, class P, class A> ostream &operator<<(ostream &os, unordered_map<S, T, H, P, A> M) { os /*name(S) << " is"*/ << "\n"; for (auto ELE : M) os << " " << name(M) << "[" << ELE.xx << "] = " << ELE.yy << "\n"; return os; /*<<"\n";*/ } template <class T, class C, class A> ostream &operator<<(ostream &os, multiset<T, C, A> S) { os /*name(S) << " is"*/ << "["; int i = 0; for (auto ELE : S) { os << ELE; if (i < sz(S) - 1) os << ", "; i++; } return os << "]"; /*<<"\n"; */ } template <class T, class R> ostream &operator<<(ostream &os, gp_hash_table<T, null_type, custom_hash<R>> S) { os /*name(S) << " is"*/ << " ["; int i = 0; for (auto ELE : S) { os << ELE; if (i < sz(S) - 1) os << ", "; i++; } return os << "]"; /*<<"\n"; */ } template <class T, class Z, class R> ostream &operator<<(ostream &os, gp_hash_table<T, Z, custom_hash<R>> M) { os /*name(S) << " is"*/ << "\n"; for (auto ELE : M) os << " " << name(M) << "[" << ELE.xx << "] = " << ELE.yy << "\n"; return os; /*<<"\n";*/ } template <class T, class R> ostream &operator<<(ostream &os, cc_hash_table<T, null_type, custom_hash<R>> S) { os /*name(S) << " is"*/ << " ["; int i = 0; for (auto ELE : S) { os << ELE; if (i < sz(S) - 1) os << ", "; i++; } return os << "]"; /*<<"\n"; */ } template <class T, class Z, class R> ostream &operator<<(ostream &os, cc_hash_table<T, Z, custom_hash<R>> M) { os /*name(S) << " is"*/ << "\n"; for (auto ELE : M) os << " " << name(M) << "[" << ELE.xx << "] = " << ELE.yy << "\n"; return os; /*<<"\n";*/ } template <class L, class R> istream &operator>>(ostream &os, pair<L, R> &P) { return os >> P.xx >> P.yy; } template <class L> istream &operator>>(istream &os, vector<L> &V) { FOR(i, 0, sz(V)) os >> V[i]; return os; } template <class L> istream &operator>>(istream &os, vector<vector<L>> &V) { FOR(i, 0, sz(V)) os >> V[i]; return os; } using st = string; typedef long long int li; typedef pair<int, int> ii; typedef pair<int, ii> iii; typedef tuple<int, int> i2; typedef tuple<int, int, int> i3; typedef vector<int> vi; typedef vector<ii> vii; typedef vector<i2> vi2; typedef vector<i3> vi3; typedef vector<iii> viii; typedef vector<vi> vvi; typedef vector<vvi> vvvi; typedef pair<li, li> ll; typedef pair<li, ll> lll; typedef tuple<li, li> l2; typedef tuple<li, li, li> l3; typedef vector<li> vl; typedef vector<ll> vll; typedef vector<l2> vl2; typedef vector<l3> vl3; typedef vector<lll> vlll; typedef vector<vl> vvl; typedef vector<vvl> vvvl; typedef double db; typedef complex<db> cd; typedef vector<cd> vcd; template <class S> using ve = vector<S>; template <class S> using gr = greater<S>; template <class S> using le = less<S>; template <class S, class T = le<S>> using ms = multiset<S, T>; template <class S, class T = null_type, class R = size_t> using gp = gp_hash_table<S, T, custom_hash<R>>; template <class S, class T = null_type, class R = size_t> using cc = cc_hash_table<S, T, custom_hash<R>>; template <class S, class T, class R = size_t> using um = unordered_map<S, T, custom_hash<R>>; template <class S, class R = size_t> using us = unordered_set<S, custom_hash<R>>; const double pi = 2 * acos(0.0); const int oo = 0x3f3f3f3f; // don't use for long long const double inf = 1.0 / 0.0; int main() { ios_base::sync_with_stdio(0); int n; tk(n); vi a(n, 0); tk(a); vi b(n, -1); vi ans; FOR(i, n, 0) { int s = 0; int en = 0; for (int j = 2 * (i + 1); j <= n; j += i + 1) { s += b[j]; en = 1; } s %= 2; if (en) b[i] = (2 - s + a[i]) % 2; else b[i] = a[i]; if (b[i]) ans.pb(i + 1); } cout << sz(ans) << "\n"; SEL(v, ans) cout << v << " "; nl; return 0; }
/* ** Vishal Raj Roy ** Indian Institute of Technology Kharagpur */ #include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> using namespace std; using namespace __gnu_pbds; #define pb push_back #define eb emplace_back #define mp make_pair #define mt make_tuple #define lb lower_bound #define ub upper_bound #define all(x) x.begin(), x.end() #define at(X, N) get<N>(X) #define xx first #define yy second #define sz(x) ((int)x.size()) #define nl cout << "\n"; // FOR(i,1,10) gives 1,2,3,....,9 and FOR(i,10,1) gives 9,8,....,1 also FOR(it, // end(v), begin(v)) and FOR(it, begin(v), end(v)) #define FOR(i, begin, end) \ for (__typeof(end) i = (begin) - ((begin) > (end)); \ i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end))) #define SEL(X, C) for (auto &X : C) #define ima INT_MAX #define imi INT_MIN #define lma LLONG_MAX #define lmi LLONG_MIN #define name(X) (#X) #define tl(args...) \ { \ string _s = #args; \ replace(_s.begin(), _s.end(), ',', ' '); \ stringstream _ss(_s); \ istream_iterator<string> _it(_ss); \ tell(_it, args); \ } #define tk(args...) take(args); void tell(istream_iterator<string> it) {} template <typename T, typename... Args> void tell(istream_iterator<string> it, T a, Args... args) { cout << *it << " = " << a << "\n"; tell(++it, args...); } void take() {} template <typename T, typename... Args> void take(T &a, Args &...args) { cin >> a; take(args...); } template <class T> struct custom_hash { static uint64_t splitmix64(uint64_t x) { x += 0x9e3779b97f4a7c15; x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9; x = (x ^ (x >> 27)) * 0x94d049bb133111eb; return x ^ (x >> 31); } T operator()(uint64_t x) const { static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count(); return splitmix64(x + FIXED_RANDOM); } T operator()(tuple<uint64_t, uint64_t> x) const { static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count(); return splitmix64(get<0>(x) + FIXED_RANDOM) ^ (splitmix64(get<1>(x) + FIXED_RANDOM) >> 1); } }; // T operator()(pair<uint64_t,uint64_t> x) const { static const uint64_t // FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count(); // return splitmix64(x.first + FIXED_RANDOM)^(splitmix64(x.second + // FIXED_RANDOM) >> 1); } }; template <class L, class R> ostream &operator<<(ostream &os, pair<L, R> P) { return os << "(" << P.xx << "," << P.yy << ")"; } template <class L, class R> ostream &operator<<(ostream &os, tuple<L, R> P) { return os << "(" << get<0>(P) << "," << get<1>(P) << ")"; } template <class L, class R, class S> ostream &operator<<(ostream &os, tuple<L, R, S> P) { return os << "(" << get<0>(P) << "," << get<1>(P) << "," << get<2>(P) << ")"; } template <class T, class A> ostream &operator<<(ostream &os, vector<T, A> V) { os /*<< name(V)<< " is "*/ << "\n"; FOR(i, 0, sz(V)) os << " " << name(V) << "[" << i << "] = " << V[i] << "\n"; return os; /*<<"\n";*/ } template <class T, class H, class P, class A> ostream &operator<<(ostream &os, unordered_set<T, H, P, A> S) { os /*name(S) << " is"*/ << " ["; int i = 0; for (auto ELE : S) { os << ELE; if (i < sz(S) - 1) os << ", "; i++; } return os << "]"; /*<<"\n"; */ } template <class S, class T, class H, class P, class A> ostream &operator<<(ostream &os, unordered_map<S, T, H, P, A> M) { os /*name(S) << " is"*/ << "\n"; for (auto ELE : M) os << " " << name(M) << "[" << ELE.xx << "] = " << ELE.yy << "\n"; return os; /*<<"\n";*/ } template <class T, class C, class A> ostream &operator<<(ostream &os, multiset<T, C, A> S) { os /*name(S) << " is"*/ << "["; int i = 0; for (auto ELE : S) { os << ELE; if (i < sz(S) - 1) os << ", "; i++; } return os << "]"; /*<<"\n"; */ } template <class T, class R> ostream &operator<<(ostream &os, gp_hash_table<T, null_type, custom_hash<R>> S) { os /*name(S) << " is"*/ << " ["; int i = 0; for (auto ELE : S) { os << ELE; if (i < sz(S) - 1) os << ", "; i++; } return os << "]"; /*<<"\n"; */ } template <class T, class Z, class R> ostream &operator<<(ostream &os, gp_hash_table<T, Z, custom_hash<R>> M) { os /*name(S) << " is"*/ << "\n"; for (auto ELE : M) os << " " << name(M) << "[" << ELE.xx << "] = " << ELE.yy << "\n"; return os; /*<<"\n";*/ } template <class T, class R> ostream &operator<<(ostream &os, cc_hash_table<T, null_type, custom_hash<R>> S) { os /*name(S) << " is"*/ << " ["; int i = 0; for (auto ELE : S) { os << ELE; if (i < sz(S) - 1) os << ", "; i++; } return os << "]"; /*<<"\n"; */ } template <class T, class Z, class R> ostream &operator<<(ostream &os, cc_hash_table<T, Z, custom_hash<R>> M) { os /*name(S) << " is"*/ << "\n"; for (auto ELE : M) os << " " << name(M) << "[" << ELE.xx << "] = " << ELE.yy << "\n"; return os; /*<<"\n";*/ } template <class L, class R> istream &operator>>(ostream &os, pair<L, R> &P) { return os >> P.xx >> P.yy; } template <class L> istream &operator>>(istream &os, vector<L> &V) { FOR(i, 0, sz(V)) os >> V[i]; return os; } template <class L> istream &operator>>(istream &os, vector<vector<L>> &V) { FOR(i, 0, sz(V)) os >> V[i]; return os; } using st = string; typedef long long int li; typedef pair<int, int> ii; typedef pair<int, ii> iii; typedef tuple<int, int> i2; typedef tuple<int, int, int> i3; typedef vector<int> vi; typedef vector<ii> vii; typedef vector<i2> vi2; typedef vector<i3> vi3; typedef vector<iii> viii; typedef vector<vi> vvi; typedef vector<vvi> vvvi; typedef pair<li, li> ll; typedef pair<li, ll> lll; typedef tuple<li, li> l2; typedef tuple<li, li, li> l3; typedef vector<li> vl; typedef vector<ll> vll; typedef vector<l2> vl2; typedef vector<l3> vl3; typedef vector<lll> vlll; typedef vector<vl> vvl; typedef vector<vvl> vvvl; typedef double db; typedef complex<db> cd; typedef vector<cd> vcd; template <class S> using ve = vector<S>; template <class S> using gr = greater<S>; template <class S> using le = less<S>; template <class S, class T = le<S>> using ms = multiset<S, T>; template <class S, class T = null_type, class R = size_t> using gp = gp_hash_table<S, T, custom_hash<R>>; template <class S, class T = null_type, class R = size_t> using cc = cc_hash_table<S, T, custom_hash<R>>; template <class S, class T, class R = size_t> using um = unordered_map<S, T, custom_hash<R>>; template <class S, class R = size_t> using us = unordered_set<S, custom_hash<R>>; const double pi = 2 * acos(0.0); const int oo = 0x3f3f3f3f; // don't use for long long const double inf = 1.0 / 0.0; int main() { ios_base::sync_with_stdio(0); int n; tk(n); vi a(n, 0); tk(a); vi b(n, -1); vi ans; FOR(i, n, 0) { int s = 0; int en = 0; for (int j = 2 * (i + 1); j <= n; j += i + 1) { s += b[j - 1]; en = 1; } s %= 2; if (en) b[i] = (2 - s + a[i]) % 2; else b[i] = a[i]; if (b[i]) ans.pb(i + 1); } cout << sz(ans) << "\n"; SEL(v, ans) cout << v << " "; nl; return 0; }
[ "assignment.change" ]
778,200
778,201
u027266662
cpp
p02972
#include <algorithm> #include <iostream> #include <map> #include <math.h> #include <numeric> #include <queue> #include <set> #include <sstream> #include <stack> #include <utility> #include <vector> typedef long long ll; const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1}; const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1}; const int dr[4] = {-1, 0, 1, 0}; const int dc[4] = {0, 1, 0, -1}; const int INF = 1e9; #define FOR(i, a, n) for (int i = (int)(a); i < (int)(n); ++i) #define REP(i, n) FOR(i, 0, n) #define SORT(a) sort(a.begin(), a.end()) #define REVERSE(a) reverse(a.begin(), a.end()) int guki(int a) { if (a % 2 == 0) return 0; else return 1; } int gcd(int a, int b) { if (a % b == 0) { return b; } else { return (gcd(b, a % b)); } } int lcm(int a, int b) { int x = gcd(a, b); return (a * b / x); } using namespace std; ll k(ll a) { a--; ll ans = 0; while (a != 0) { ans += a; a--; } return ans; } char grid[505][505]; int h, w; pair<int, int> st, en; int score[505][505]; void bfs(int x, int y) { queue<pair<int, int>> Q; score[x][y] = 0; Q.push(make_pair(x, y)); while (!Q.empty()) { pair<int, int> p = Q.front(); Q.pop(); int hh = p.second; int ww = p.first; REP(i, 4) { int nx = ww + dr[i]; int ny = hh + dc[i]; if (nx < 0 || w <= nx || ny < 0 || h <= ny) { continue; } if (grid[nx][ny] == '#' && score[nx][ny] > (score[x][y] + 1)) { Q.push(make_pair(nx, ny)); score[nx][ny] = score[x][y] + 1; } if (score[nx][ny] > (score[x][y] + 1) && grid[nx][ny] != '#') { Q.push(make_pair(nx, ny)); score[nx][ny] = score[x][y]; } } } } int n, m; int a[1500]; int dfs(int x, int cnt, int i) { if (cnt == 0) return x; if (x >= m) return 0; x = max(x, dfs(x + a[i], cnt - 1, i + 1)); return x; } int main() { int n; cin >> n; vector<int> a(n + 1), b, c(n + 1); FOR(i, 1, n + 1) { cin >> a[i]; } int ans = 0; for (int i = n; 0 < i; i--) { int x = 0; for (int j = i; j <= n; j += i) { x += a[j]; } if (x % 2 != a[i]) { c[i] = 1; ans++; } } cout << ans << endl; for (int i = 1; i <= n; i++) { if (c[i] == 1) { cout << i << " "; } } cout << endl; }
#include <algorithm> #include <iostream> #include <map> #include <math.h> #include <numeric> #include <queue> #include <set> #include <sstream> #include <stack> #include <utility> #include <vector> typedef long long ll; const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1}; const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1}; const int dr[4] = {-1, 0, 1, 0}; const int dc[4] = {0, 1, 0, -1}; const int INF = 1e9; #define FOR(i, a, n) for (int i = (int)(a); i < (int)(n); ++i) #define REP(i, n) FOR(i, 0, n) #define SORT(a) sort(a.begin(), a.end()) #define REVERSE(a) reverse(a.begin(), a.end()) int guki(int a) { if (a % 2 == 0) return 0; else return 1; } int gcd(int a, int b) { if (a % b == 0) { return b; } else { return (gcd(b, a % b)); } } int lcm(int a, int b) { int x = gcd(a, b); return (a * b / x); } using namespace std; ll k(ll a) { a--; ll ans = 0; while (a != 0) { ans += a; a--; } return ans; } char grid[505][505]; int h, w; pair<int, int> st, en; int score[505][505]; void bfs(int x, int y) { queue<pair<int, int>> Q; score[x][y] = 0; Q.push(make_pair(x, y)); while (!Q.empty()) { pair<int, int> p = Q.front(); Q.pop(); int hh = p.second; int ww = p.first; REP(i, 4) { int nx = ww + dr[i]; int ny = hh + dc[i]; if (nx < 0 || w <= nx || ny < 0 || h <= ny) { continue; } if (grid[nx][ny] == '#' && score[nx][ny] > (score[x][y] + 1)) { Q.push(make_pair(nx, ny)); score[nx][ny] = score[x][y] + 1; } if (score[nx][ny] > (score[x][y] + 1) && grid[nx][ny] != '#') { Q.push(make_pair(nx, ny)); score[nx][ny] = score[x][y]; } } } } int n, m; int a[1500]; int dfs(int x, int cnt, int i) { if (cnt == 0) return x; if (x >= m) return 0; x = max(x, dfs(x + a[i], cnt - 1, i + 1)); return x; } int main() { int n; cin >> n; vector<int> a(n + 1), b, c(n + 1); FOR(i, 1, n + 1) { cin >> a[i]; } int ans = 0; for (int i = n; 0 < i; i--) { int x = 0; for (int j = i; j <= n; j += i) { x += c[j]; } if (x % 2 != a[i]) { c[i] = 1; ans++; } } cout << ans << endl; for (int i = 1; i <= n; i++) { if (c[i] == 1) { cout << i << " "; } } cout << endl; }
[ "assignment.value.change", "identifier.change" ]
778,204
778,205
u339558464
cpp
p02972
#include <algorithm> #include <cmath> #include <functional> #include <iostream> #include <queue> #include <string> #include <vector> using namespace std; using ll = long long; template <typename T> T In() { T t; cin >> t; return t; } template <typename T> vector<T> ReadVec1(int N) { vector<T> vec(N); for (int i = 0; i < N; i++) vec[i] = In<T>(); return move(vec); } template <typename T> vector<vector<T>> Vec2(int i, int j, T ini = 0) { vector<vector<T>> vec(i, vector<T>(j, ini)); return move(vec); } template <typename T> vector<vector<vector<T>>> Vec3(int i, int j, int k, T ini = 0) { vector<vector<vector<T>>> vec(i, vector<vector<T>>(j, vector<T>(k, ini))); return move(vec); } int count(const vector<int> &bs, int i) { int c = 0; for (int n = 1; i * n < bs.size(); n++) { if (bs[i * n - 1] == 1) c++; } return c; } int main() { int N = In<int>(); vector<int> as(N, 0), bs(N, 0); for (int i = 1; i <= N; i++) { as[i - 1] = In<int>(); } int num = 0; for (int i = N; i > 0; i--) { if (count(bs, i) % 2 != as[i - 1]) { bs[i - 1] = 1; num++; } } cout << num << endl; for (int i = 1; i <= N; i++) { if (bs[i - 1] == 1) cout << i << endl; } }
#include <algorithm> #include <cmath> #include <functional> #include <iostream> #include <queue> #include <string> #include <vector> using namespace std; using ll = long long; template <typename T> T In() { T t; cin >> t; return t; } template <typename T> vector<T> ReadVec1(int N) { vector<T> vec(N); for (int i = 0; i < N; i++) vec[i] = In<T>(); return move(vec); } template <typename T> vector<vector<T>> Vec2(int i, int j, T ini = 0) { vector<vector<T>> vec(i, vector<T>(j, ini)); return move(vec); } template <typename T> vector<vector<vector<T>>> Vec3(int i, int j, int k, T ini = 0) { vector<vector<vector<T>>> vec(i, vector<vector<T>>(j, vector<T>(k, ini))); return move(vec); } int count(const vector<int> &bs, int i) { int c = 0; for (int n = 1; i * n <= bs.size(); n++) { if (bs[i * n - 1] == 1) c++; } return c; } int main() { int N = In<int>(); vector<int> as(N, 0), bs(N, 0); for (int i = 1; i <= N; i++) { as[i - 1] = In<int>(); } int num = 0; for (int i = N; i > 0; i--) { if (count(bs, i) % 2 != as[i - 1]) { bs[i - 1] = 1; num++; } } cout << num << endl; for (int i = 1; i <= N; i++) { if (bs[i - 1] == 1) cout << i << endl; } }
[ "expression.operator.compare.change", "control_flow.loop.for.condition.change", "expression.off_by_one", "expression.operation.binary.change" ]
778,209
778,210
u991692050
cpp
p02972
#include <algorithm> #include <bitset> #include <cmath> #include <cstdio> #include <fstream> #include <iomanip> #include <iostream> #include <limits.h> #include <map> #include <numeric> #include <queue> #include <set> #include <stack> #include <string> #include <unordered_map> #include <utility> #include <vector> #define int long long using namespace std; using P = pair<int, int>; using ll = long long; using prique = priority_queue<int>; const int MOD = 1000000007; const int INF = LLONG_MAX / 3; const int MAX = 510000; signed main() { int n; cin >> n; bool a[214514]; for (int i = 0; i < n; i++) { cin >> a[i]; } int ans[214514]; for (int i = n - 1; i >= 0; i--) { if (a[i] == true) { ans[i] = 1; for (int j = 1; j <= sqrt(i); j++) { if ((i + 1) % j == 0) { a[j - 1] = !a[j - 1]; if (!((i + 1) / j == j)) { a[(i + 1) / j - 1] = !a[(i + 1) / j - 1]; } } } } else { ans[i] = 0; } } int m = 0; for (int i = 0; i < n; i++) { if (ans[i] != 0) m++; } cout << m << endl; for (int i = 0; i < n; i++) { if (ans[i] == 1) cout << i + 1 << " "; } cout << endl; return 0; }
#include <algorithm> #include <bitset> #include <cmath> #include <cstdio> #include <fstream> #include <iomanip> #include <iostream> #include <limits.h> #include <map> #include <numeric> #include <queue> #include <set> #include <stack> #include <string> #include <unordered_map> #include <utility> #include <vector> #define int long long using namespace std; using P = pair<int, int>; using ll = long long; using prique = priority_queue<int>; const int MOD = 1000000007; const int INF = LLONG_MAX / 3; const int MAX = 510000; signed main() { int n; cin >> n; bool a[214514]; for (int i = 0; i < n; i++) { cin >> a[i]; } int ans[214514]; for (int i = n - 1; i >= 0; i--) { if (a[i] == true) { ans[i] = 1; for (int j = 1; j <= sqrt(i + 1); j++) { if ((i + 1) % j == 0) { a[j - 1] = !a[j - 1]; if (!((i + 1) / j == j)) { a[(i + 1) / j - 1] = !a[(i + 1) / j - 1]; } } } } else { ans[i] = 0; } } int m = 0; for (int i = 0; i < n; i++) { if (ans[i] != 0) m++; } cout << m << endl; for (int i = 0; i < n; i++) { if (ans[i] == 1) cout << i + 1 << " "; } cout << endl; return 0; }
[ "control_flow.branch.if.condition.change", "control_flow.loop.for.condition.change", "misc.off_by_one" ]
778,211
778,212
u033620890
cpp
p02972
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef long double ld; #define rep(i, n) for (int i = 0; i < n; i++) int main(void) { ll n; cin >> n; ll a[n], b[n]; rep(i, n) { cin >> a[i]; b[i] = 0; } for (int i = n; i > 0; i--) { ll tmp = i; ll count = 0; while (n >= tmp) { count += b[tmp - 1]; tmp *= 2; } if (a[i - 1] % 2 != count % 2) { b[i - 1]++; } } ll count = 0; rep(i, n) { if (b[i] == 1) { count++; } } cout << count << endl; if (count) { rep(i, n) { if (b[i] == 1) cout << i + 1 << " "; } } cout << endl; return 0; }
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef long double ld; #define rep(i, n) for (int i = 0; i < n; i++) int main(void) { ll n; cin >> n; ll a[n], b[n]; rep(i, n) { cin >> a[i]; b[i] = 0; } for (int i = n; i > 0; i--) { ll tmp = i; ll count = 0; while (n >= tmp) { count += b[tmp - 1]; tmp += i; } if (a[i - 1] % 2 != count % 2) { b[i - 1]++; } } ll count = 0; rep(i, n) { if (b[i] == 1) { count++; } } cout << count << endl; if (count) { rep(i, n) { if (b[i] == 1) cout << i + 1 << " "; } } cout << endl; return 0; }
[ "assignment.change" ]
778,219
778,220
u326152409
cpp
p02972
#include <iostream> #include <vector> using namespace std; int main(void) { int N; cin >> N; vector<int> a(N, 0); vector<int> b(N, 0); int M = 0; for (int i = 0; i < N; i++) { cin >> a[i]; } for (long long i = N - 1; i >= 0; i--) { int sum = 0; for (long long j = 2 * (i + 1); j < N; j = j + (i + 1)) { sum += b[j]; } sum %= 2; if (sum == a[i]) { b[i] = 0; } else { b[i] = 1; M++; } } cout << M << endl; for (int i = 0; i < N; i++) { if (b[i] == 1) { cout << i + 1 << " "; } } cout << endl; return 0; }
#include <iostream> #include <vector> using namespace std; int main(void) { int N; cin >> N; vector<int> a(N, 0); vector<int> b(N, 0); int M = 0; for (int i = 0; i < N; i++) { cin >> a[i]; } for (int i = N - 1; i >= 0; i--) { int sum = 0; for (int j = 2 * i + 1; j < N; j = j + (i + 1)) { sum += b[j]; } sum %= 2; if (sum == a[i]) { b[i] = 0; } else { b[i] = 1; M++; } } cout << M << endl; for (int i = 0; i < N; i++) { if (b[i] == 1) { cout << i + 1 << " "; } } cout << endl; return 0; }
[ "control_flow.loop.for.initializer.change", "variable_declaration.type.primitive.change", "variable_declaration.type.narrow.change" ]
778,223
778,224
u148959786
cpp
p02972
#include <iostream> #include <vector> using namespace std; int main(void) { int N; cin >> N; vector<int> a(N, 0); vector<int> b(N, 0); int M = 0; for (int i = 0; i < N; i++) { cin >> a[i]; } for (int i = N - 1; i >= 0; i--) { int sum = 0; for (int j = 2 * (i + 1); j < N; j = j + (i + 1)) { sum += b[j]; } sum %= 2; if (sum == a[i]) { b[i] = 0; } else { b[i] = 1; M++; } } cout << M << endl; for (int i = 0; i < N; i++) { if (b[i] == 1) { cout << i + 1 << " "; } } cout << endl; return 0; }
#include <iostream> #include <vector> using namespace std; int main(void) { int N; cin >> N; vector<int> a(N, 0); vector<int> b(N, 0); int M = 0; for (int i = 0; i < N; i++) { cin >> a[i]; } for (int i = N - 1; i >= 0; i--) { int sum = 0; for (int j = 2 * i + 1; j < N; j = j + (i + 1)) { sum += b[j]; } sum %= 2; if (sum == a[i]) { b[i] = 0; } else { b[i] = 1; M++; } } cout << M << endl; for (int i = 0; i < N; i++) { if (b[i] == 1) { cout << i + 1 << " "; } } cout << endl; return 0; }
[]
778,225
778,224
u148959786
cpp
p02972
#include <iostream> #include <vector> using namespace std; int main(void) { int N; cin >> N; vector<int> a(N, 0); vector<int> b(N, 0); int M = 0; for (int i = 0; i < N; i++) { cin >> a[i]; } for (int i = N - 1; i >= 0; i--) { int sum = 0; for (int j = 2 * (i + 1); j < N + 1; j = j + (i + 1)) { sum += b[j]; } sum %= 2; if (sum == a[i]) { b[i] = 0; } else { b[i] = 1; M++; } } cout << M << endl; for (int i = 0; i < N; i++) { if (b[i] == 1) { cout << i + 1 << " "; } } cout << endl; return 0; }
#include <iostream> #include <vector> using namespace std; int main(void) { int N; cin >> N; vector<int> a(N, 0); vector<int> b(N, 0); int M = 0; for (int i = 0; i < N; i++) { cin >> a[i]; } for (int i = N - 1; i >= 0; i--) { int sum = 0; for (int j = 2 * i + 1; j < N; j = j + (i + 1)) { sum += b[j]; } sum %= 2; if (sum == a[i]) { b[i] = 0; } else { b[i] = 1; M++; } } cout << M << endl; for (int i = 0; i < N; i++) { if (b[i] == 1) { cout << i + 1 << " "; } } cout << endl; return 0; }
[ "control_flow.loop.for.condition.change", "expression.operation.binary.remove" ]
778,226
778,224
u148959786
cpp
p02972
#include <iostream> #include <vector> using namespace std; int main(void) { int N; cin >> N; vector<int> a(N, 0); vector<int> b(N, 0); int M = 0; for (int i = 0; i < N; i++) { cin >> a[i]; } for (int i = N - 1; i >= 0; i--) { int sum = 0; for (int j = 2 * (i + 1); j < N; j = j + (i + 1)) { sum += b[j]; } sum %= 2; if (sum == a[i]) { b[i] = 0; } else { b[i] = 1; M++; } } cout << M << endl; for (int i = 0; i < N; i++) { if (b[i] == 1) { cout << i + 1 << " "; } } cout << endl; return 0; }
#include <iostream> #include <vector> using namespace std; int main(void) { int N; cin >> N; vector<int> a(N, 0); vector<int> b(N, 0); int M = 0; for (int i = 0; i < N; i++) { cin >> a[i]; } for (int i = N - 1; i >= 0; i--) { int sum = 0; // for (int j = 2 * (i + 1); j < N; j = j + (i + 1)) { for (int j = (i + 1); i + j < N; j = j + (i + 1)) { sum += b[i + j]; } sum %= 2; if (sum == a[i]) { b[i] = 0; } else { b[i] = 1; M++; } } cout << M << endl; for (int i = 0; i < N; i++) { if (b[i] == 1) { cout << i + 1 << " "; } } cout << endl; return 0; }
[ "control_flow.loop.for.initializer.change", "expression.operation.binary.remove", "control_flow.loop.for.condition.change", "assignment.change" ]
778,225
778,227
u148959786
cpp
p02972
#include <algorithm> #include <iostream> #include <math.h> #include <string> #include <vector> using namespace std; using std::swap; // priceをキーに降順でソート // sort(fruits.begin(), fruits.end(), // [](const fruit& x, const fruit& y) { return x.price > y.price;}); /* int main() { long long int S; int r; std::cin >> r; S= 3*r*r; std::cout << S << std::endl; return 0; } */ /* int main(){ int K, D; int ans; std::cin >> K >> D; ans = (K+2*D)/(2*D+1); std::cout << ans << std::endl; } */ /* int main(){ int N; int max=0; int sem_max=0; std::cin >> N; int A[N]; for(int i=0; i<N; i++){ std::cin >> A[i]; } for(int i=0; i<N; i++){ if(A[i]>max){ sem_max = max; max=A[i]; } else if(A[i]>sem_max){ sem_max=A[i]; } } for(int i=0; i<N; i++){ if(A[i]==max){ std::cout << sem_max << std::endl; } else{ std::cout << max << std::endl; } } return 0; } */ int main() { int N; std::cin >> N; int a[N + 1]; int b[N + 1]; int count = 0; for (int i = 1; i < N + 1; i++) { std::cin >> a[i]; } for (int i = 1; i < N + 1; i++) { b[i] = 0; } for (int i = 0; i < N; i++) { for (int j = 1; j < N / (N - i); j++) { b[N - i] += b[j * (N - i)]; } b[N - i] = (b[N - i] + a[N - i]) % 2; } for (int i = 1; i < N + 1; i++) { if (b[i] == 1) { count++; } } std::cout << count << std::endl; for (int i = 1; i < N + 1; i++) { if (b[i] == 1) { std::cout << i << endl; } } return 0; }
#include <algorithm> #include <iostream> #include <math.h> #include <string> #include <vector> using namespace std; using std::swap; // priceをキーに降順でソート // sort(fruits.begin(), fruits.end(), // [](const fruit& x, const fruit& y) { return x.price > y.price;}); /* int main() { long long int S; int r; std::cin >> r; S= 3*r*r; std::cout << S << std::endl; return 0; } */ /* int main(){ int K, D; int ans; std::cin >> K >> D; ans = (K+2*D)/(2*D+1); std::cout << ans << std::endl; } */ /* int main(){ int N; int max=0; int sem_max=0; std::cin >> N; int A[N]; for(int i=0; i<N; i++){ std::cin >> A[i]; } for(int i=0; i<N; i++){ if(A[i]>max){ sem_max = max; max=A[i]; } else if(A[i]>sem_max){ sem_max=A[i]; } } for(int i=0; i<N; i++){ if(A[i]==max){ std::cout << sem_max << std::endl; } else{ std::cout << max << std::endl; } } return 0; } */ int main() { int N; std::cin >> N; int a[N + 1]; int b[N + 1]; int count = 0; for (int i = 1; i < N + 1; i++) { std::cin >> a[i]; } for (int i = 1; i < N + 1; i++) { b[i] = 0; } for (int i = 0; i < N; i++) { for (int j = 1; j < N / (N - i); j++) { b[N - i] += b[(j + 1) * (N - i)]; } b[N - i] = (b[N - i] + a[N - i]) % 2; } for (int i = 1; i < N + 1; i++) { if (b[i] == 1) { count++; } } std::cout << count << std::endl; for (int i = 1; i < N + 1; i++) { if (b[i] == 1) { std::cout << i << endl; } } return 0; }
[]
778,230
778,231
u786283792
cpp
p02972
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<int, int> P; #define rep(i, n) for (int i = 0; i < n; ++i) #define MOD (int)1e9 + 7 #define INF (int)2e9 int main() { int n; cin >> n; int a[n], b[n] = {}; rep(i, n) { cin >> a[i]; } int m = 0; for (int i = n; i >= 1; i--) { int ma = n / i * i; int s = 0; for (int j = ma; j > ma; j -= i) { s += b[j]; } if (s % 2 != a[i - 1]) { b[i - 1] = 1; m++; } } cout << m << endl; for (int i = 0; i < n; i++) { if (b[i] == 1) { cout << i + 1 << " "; } } cout << endl; // printf("%d\n", N); return 0; }
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<int, int> P; #define rep(i, n) for (int i = 0; i < n; ++i) #define MOD (int)1e9 + 7 #define INF (int)2e9 int main() { int n; cin >> n; int a[n], b[n] = {}; rep(i, n) { cin >> a[i]; } int m = 0; for (int i = n; i >= 1; i--) { int ma = n / i * i; int s = 0; for (int j = ma; j > i; j -= i) { s += b[j - 1]; } if (s % 2 != a[i - 1]) { b[i - 1] = 1; m++; } } cout << m << endl; for (int i = 0; i < n; i++) { if (b[i] == 1) { cout << i + 1 << " "; } } cout << endl; // printf("%d\n", N); return 0; }
[ "identifier.change", "control_flow.loop.for.condition.change", "expression.operation.binary.change", "assignment.change" ]
778,232
778,233
u263654061
cpp
p02972
/* C++14(GCC5.4.1) */ #include <bits/stdc++.h> using namespace std; using ll = long long; int main(void) { ll n; cin >> n; ll a[n]; for (ll i = 1; i <= n; i++) { cin >> a[i]; } ll b[n + 1] = {0}; // 後ろから見ていく // 後ろ半分はaと一致 for (ll i = n; i >= 1; i--) { ll sum_i = 0; for (ll j = 2 * i; j < n; j += i) { sum_i += b[j]; } if (sum_i % 2 == a[i]) b[i] = 0; else b[i] = 1; } // M=counter(出力用) ll counter = 0; for (ll i = 1; i <= n; i++) { if (b[i] == 1) counter++; } // 出力(-1になる事ないよ、これ) cout << counter << "\n"; for (ll i = 1; i <= n; i++) { if (b[i] == 1) cout << i << " "; } return 0; }
/* C++14(GCC5.4.1) */ #include <bits/stdc++.h> using namespace std; using ll = long long; int main(void) { ll n; cin >> n; ll a[n]; for (ll i = 1; i <= n; i++) { cin >> a[i]; } ll b[n + 1] = {0}; // 後ろから見ていく // 後ろ半分はaと一致 for (ll i = n; i >= 1; i--) { ll sum_i = 0; for (ll j = i; j <= n; j += i) { sum_i += b[j]; } if (sum_i % 2 == a[i]) b[i] = 0; else b[i] = 1; } // M=counter(出力用) ll counter = 0; for (ll i = 1; i <= n; i++) { if (b[i] == 1) counter++; } // 出力(-1になる事ないよ、これ) cout << counter << "\n"; for (ll i = 1; i <= n; i++) { if (b[i] == 1) cout << i << " "; } return 0; }
[ "control_flow.loop.for.initializer.change", "expression.operation.binary.remove", "expression.operator.compare.change", "control_flow.loop.for.condition.change", "expression.off_by_one", "expression.operation.binary.change" ]
778,234
778,235
u900688325
cpp
p02972
#include "bits/stdc++.h" using namespace std; typedef vector<int> VI; typedef vector<VI> VVI; typedef vector<string> VS; typedef pair<int, int> PII; typedef vector<pair<int, int>> VPII; typedef long long LL; #define SORT_ASC(c) sort((c).begin(), (c).end()) #define SORT_DESC(c) \ sort((c).begin(), (c).end(), greater<typeof((c).begin())>()) #define FOR(i, a, b) for (int i = (a); i < (b); ++i) #define REP(i, n) FOR(i, 0, n) #define SIZE(a) int((a).size()) const double EPS = 1e-10; const double PI = acos(-1.0); const int INT_LARGE = 1000000100; // debug #define dump(x) cerr << #x << " = " << (x) << endl; #define debug(x) \ cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" \ << " " << __FILE__ << endl; void Main() { int n; cin >> n; n++; VI a(n, 0); VI r(n, 0); FOR(i, 1, n) { cin >> a[i]; } for (int i = n - 1; i > 0; i--) { int sum = 0; for (int j = i * 2; j < n; j += i) { sum += a[j]; } if (sum % 2 == a[i]) { a[i] = 0; } else { a[i] = 1; } } int sum = 0; FOR(i, 1, n) { sum += a[i]; } cout << sum << endl; bool flag = false; FOR(i, 1, n) { if (flag) { cout << " "; } if (a[i] != 0) { cout << "1"; flag = true; } } cout << endl; return; } int main() { cin.tie(nullptr); ios_base::sync_with_stdio(false); cout << fixed << setprecision(15); Main(); return 0; }
#include "bits/stdc++.h" using namespace std; typedef vector<int> VI; typedef vector<VI> VVI; typedef vector<string> VS; typedef pair<int, int> PII; typedef vector<pair<int, int>> VPII; typedef long long LL; #define SORT_ASC(c) sort((c).begin(), (c).end()) #define SORT_DESC(c) \ sort((c).begin(), (c).end(), greater<typeof((c).begin())>()) #define FOR(i, a, b) for (int i = (a); i < (b); ++i) #define REP(i, n) FOR(i, 0, n) #define SIZE(a) int((a).size()) const double EPS = 1e-10; const double PI = acos(-1.0); const int INT_LARGE = 1000000100; // debug #define dump(x) cerr << #x << " = " << (x) << endl; #define debug(x) \ cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" \ << " " << __FILE__ << endl; void Main() { int n; cin >> n; n++; VI a(n, 0); VI r(n, 0); FOR(i, 1, n) { cin >> a[i]; } for (int i = n - 1; i > 0; i--) { int sum = 0; for (int j = i * 2; j < n; j += i) { sum += a[j]; } if (sum % 2 == a[i]) { a[i] = 0; } else { a[i] = 1; } } int sum = 0; FOR(i, 1, n) { sum += a[i]; } cout << sum << endl; bool flag = false; FOR(i, 1, n) { if (flag) { cout << " "; } if (a[i] != 0) { cout << i; flag = true; } } cout << endl; return; } int main() { cin.tie(nullptr); ios_base::sync_with_stdio(false); cout << fixed << setprecision(15); Main(); return 0; }
[ "io.output.change" ]
778,239
778,240
u987591601
cpp
p02972
#include <algorithm> #include <cmath> #include <functional> #include <iostream> #include <limits.h> #include <map> #include <queue> #include <string> #include <vector> #define rep(i, n) for (int i = 0; i < n; i++) using namespace std; typedef long long ll; ll gcd(ll a, ll b) { ll r; while ((r = a % b)) { a = b; b = r; } return b; } int main() { int n; cin >> n; vector<int> a(n + 1); for (int i = 1; i <= n; i++) { cin >> a[i]; } vector<int> b(n + 1); int m = 0; for (int i = n; i > n / 2; i--) { b[i] = a[i]; if (b[i]) { m++; } } for (int i = n / 2; i > 0; i--) { int sum = 0; for (int j = 2; i * j <= n; j++) { sum += b[j]; } if (sum % 2 == a[i]) { b[i] = 0; } else { b[i] = 1; m++; } } cout << m << endl; rep(i, n) { if (b[i + 1]) { cout << i + 1 << " "; } } return 0; }
#include <algorithm> #include <cmath> #include <functional> #include <iostream> #include <limits.h> #include <map> #include <queue> #include <string> #include <vector> #define rep(i, n) for (int i = 0; i < n; i++) using namespace std; typedef long long ll; ll gcd(ll a, ll b) { ll r; while ((r = a % b)) { a = b; b = r; } return b; } int main() { int n; cin >> n; vector<int> a(n + 1); for (int i = 1; i <= n; i++) { cin >> a[i]; } vector<int> b(n + 1); int m = 0; for (int i = n; i > n / 2; i--) { b[i] = a[i]; if (b[i]) { m++; } } for (int i = n / 2; i > 0; i--) { int sum = 0; for (int j = 2; i * j <= n; j++) { sum += b[i * j]; } if (sum % 2 == a[i]) { b[i] = 0; } else { b[i] = 1; m++; } } cout << m << endl; rep(i, n) { if (b[i + 1]) { cout << i + 1 << " "; } } return 0; }
[ "assignment.change" ]
778,241
778,242
u433162241
cpp
p02972
#include <algorithm> #include <cmath> #include <functional> #include <iostream> #include <limits.h> #include <map> #include <queue> #include <string> #include <vector> #define rep(i, n) for (int i = 0; i < n; i++) using namespace std; typedef long long ll; ll gcd(ll a, ll b) { ll r; while ((r = a % b)) { a = b; b = r; } return b; } int main() { int n; cin >> n; vector<int> a(n + 1); for (int i = 1; i <= n; i++) { cin >> a[i]; } vector<int> b(n + 1); int m = 0; for (int i = n; i > n / 2; i--) { b[i] = a[i]; if (b[i]) { m++; } } for (int i = n / 2; i > 0; i--) { int sum = 0; for (int j = 2; i * j <= n; j++) { sum += b[j]; } if (sum == a[i]) { b[i] = 0; } else { b[i] = 1; m++; } } cout << m << endl; rep(i, n) { if (b[i + 1]) { cout << i + 1 << " "; } } return 0; }
#include <algorithm> #include <cmath> #include <functional> #include <iostream> #include <limits.h> #include <map> #include <queue> #include <string> #include <vector> #define rep(i, n) for (int i = 0; i < n; i++) using namespace std; typedef long long ll; ll gcd(ll a, ll b) { ll r; while ((r = a % b)) { a = b; b = r; } return b; } int main() { int n; cin >> n; vector<int> a(n + 1); for (int i = 1; i <= n; i++) { cin >> a[i]; } vector<int> b(n + 1); int m = 0; for (int i = n; i > n / 2; i--) { b[i] = a[i]; if (b[i]) { m++; } } for (int i = n / 2; i > 0; i--) { int sum = 0; for (int j = 2; i * j <= n; j++) { sum += b[i * j]; } if (sum % 2 == a[i]) { b[i] = 0; } else { b[i] = 1; m++; } } cout << m << endl; rep(i, n) { if (b[i + 1]) { cout << i + 1 << " "; } } return 0; }
[ "assignment.change", "control_flow.branch.if.condition.change", "control_flow.loop.for.condition.change" ]
778,243
778,242
u433162241
cpp
p02972
#include <bits/stdc++.h> using namespace std; typedef long long ll; ll N; vector<ll> A, X; vector<ll> R; int main() { cin >> N; A.resize(N + 1); for (ll i = 1; i <= N; ++i) cin >> A[i]; X.resize(N + 1); for (ll i = N; i >= 1; --i) { X[i] = A[i]; for (ll k = 2 * i; k <= N; ++k) X[i] ^= X[k]; if (X[i]) R.push_back(i); } cout << R.size() << endl; bool first = true; for (ll r : R) { cout << (first ? "" : " ") << r; first = false; } return 0; }
#include <bits/stdc++.h> using namespace std; typedef long long ll; ll N; vector<ll> A, X; vector<ll> R; int main() { cin >> N; A.resize(N + 1); for (ll i = 1; i <= N; ++i) cin >> A[i]; X.resize(N + 1); for (ll i = N; i >= 1; --i) { X[i] = A[i]; for (ll k = 2 * i; k <= N; k += i) X[i] ^= X[k]; if (X[i]) R.push_back(i); } cout << R.size() << endl; bool first = true; for (ll r : R) { cout << (first ? "" : " ") << r; first = false; } return 0; }
[ "control_flow.loop.for.update.change", "assignment.change" ]
778,259
778,260
u637938292
cpp
p02972
#include <bits/stdc++.h> typedef long long ll; using namespace std; int main() { int N; cin >> N; vector<int> a(N); for (int i = 0; i < N; ++i) { cin >> a[i]; } vector<int> d(N); bool M = 0; for (int i = N; i > 0; --i) { int tmp = i; int cnt = 0; while (tmp <= N) { cnt += d[tmp - 1]; tmp += i; } if (cnt % 2 != a[i - 1]) d[i - 1] = 1, M++; } cout << M << endl; for (int i = 0; i < N; ++i) { if (d[i] == 1) cout << i + 1 << " "; } cout << endl; }
#include <bits/stdc++.h> typedef long long ll; using namespace std; int main() { int N; cin >> N; vector<int> a(N); for (int i = 0; i < N; ++i) { cin >> a[i]; } vector<int> d(N); int M = 0; for (int i = N; i > 0; --i) { int tmp = i; int cnt = 0; while (tmp <= N) { cnt += d[tmp - 1]; tmp += i; } if (cnt % 2 != a[i - 1]) d[i - 1] = 1, M++; } cout << M << endl; for (int i = 0; i < N; ++i) { if (d[i] == 1) cout << i + 1 << " "; } cout << endl; }
[ "variable_declaration.type.primitive.change" ]
778,261
778,262
u803481017
cpp
p02972
#include <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < (n); i++) using namespace std; typedef long long ll; int main() { int n; cin >> n; vector<int> a(n); rep(i, n) cin >> a[i]; // rep(i,n) cout << a[i] << endl; vector<int> b(n); int count = 0; for (int i = n - 1; i >= n / 2; i--) { b[i] = a[i]; if (b[i]) count++; // cout << i <<" " << b[i] << endl; } for (int i = n / 2 - 1; i >= 0; i--) { int mem = 0; int j = (i + 1) * 2; while (j <= n) { mem ^= a[j - 1]; j += i + 1; } b[i] = mem ^ a[i]; if (b[i]) count++; // cout << i <<" " << b[i] << endl; } cout << count << endl; rep(i, n - 1) { if (b[i]) cout << i + 1 << " "; } cout << endl; return 0; }
#include <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < (n); i++) using namespace std; typedef long long ll; int main() { int n; cin >> n; vector<int> a(n); rep(i, n) cin >> a[i]; // rep(i,n) cout << a[i] << endl; vector<int> b(n); int count = 0; for (int i = n - 1; i >= n / 2; i--) { b[i] = a[i]; if (b[i]) count++; // cout << i <<" " << b[i] << endl; } for (int i = n / 2 - 1; i >= 0; i--) { int mem = 0; int j = (i + 1) * 2; while (j <= n) { mem ^= b[j - 1]; j += i + 1; } b[i] = mem ^ a[i]; if (b[i]) count++; // cout << i <<" " << b[i] << endl; } cout << count << endl; rep(i, n) { if (b[i]) cout << i + 1 << " "; } cout << endl; return 0; }
[ "assignment.value.change", "identifier.change", "expression.operation.binary.remove" ]
778,267
778,268
u806149832
cpp
p02972
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; vector<int> a(n); for (int i = 0; i < n; i++) cin >> a.at(i); set<int> s; for (int i = n - 1; i >= 0; i--) { int num = 0; for (int j = 1; (i + 1) * j < n; j++) { if (s.count((i + 1) * j)) num++; } if (num % 2 != a.at(i)) s.insert(i + 1); } cout << s.size() << endl; for (auto i : s) cout << i << " "; }
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; vector<int> a(n); for (int i = 0; i < n; i++) cin >> a.at(i); set<int> s; for (int i = n - 1; i >= 0; i--) { int num = 0; for (int j = 1; (i + 1) * j <= n; j++) { //=の入れ忘れ? if (s.count((i + 1) * j)) num++; } if (num % 2 != a.at(i)) s.insert(i + 1); } cout << s.size() << endl; for (auto i : s) cout << i << " "; }
[ "expression.operator.compare.change", "control_flow.loop.for.condition.change", "expression.off_by_one", "expression.operation.binary.change" ]
778,271
778,272
u661308718
cpp
p02972
#include <algorithm> #include <bitset> #include <complex> #include <deque> #include <iomanip> #include <iostream> #include <map> #include <math.h> #include <queue> #include <set> #include <stack> #include <string> #include <vector> using namespace std; #define REP(i, m, n) for (int i = (int)m; i < (int)n; ++i) #define rep(i, n) REP(i, 0, n) typedef long long ll; typedef pair<int, int> pint; typedef pair<ll, int> pli; const int inf = 1e9 + 7; const ll longinf = 1LL << 60; const ll mod = 1e9 + 7; int main() { int n; cin >> n; int a[n + 1] = {}; a[0] = -1; rep(i, n) cin >> a[i + 1]; int b[n + 1] = {}; for (int i = n; i >= 1; i--) { int sum = 0; for (int j = i + i; j <= n; j += i) { sum += a[j]; } b[i] = sum + a[i]; b[i] %= 2; } int cnt = 0; rep(i, n) { if (b[i + 1] > 0) cnt++; } cout << cnt << endl; rep(i, n) { if (b[i + 1] > 0) cout << i + 1 << ' '; } cout << endl; return 0; }
#include <algorithm> #include <bitset> #include <complex> #include <deque> #include <iomanip> #include <iostream> #include <map> #include <math.h> #include <queue> #include <set> #include <stack> #include <string> #include <vector> using namespace std; #define REP(i, m, n) for (int i = (int)m; i < (int)n; ++i) #define rep(i, n) REP(i, 0, n) typedef long long ll; typedef pair<int, int> pint; typedef pair<ll, int> pli; const int inf = 1e9 + 7; const ll longinf = 1LL << 60; const ll mod = 1e9 + 7; int main() { int n; cin >> n; int a[n + 1] = {}; a[0] = -1; rep(i, n) cin >> a[i + 1]; int b[n + 1] = {}; for (int i = n; i >= 1; i--) { int sum = 0; for (int j = i + i; j <= n; j += i) { sum += b[j]; } b[i] = sum + a[i]; b[i] %= 2; } int cnt = 0; rep(i, n) { if (b[i + 1] > 0) cnt++; } cout << cnt << endl; rep(i, n) { if (b[i + 1] > 0) cout << i + 1 << ' '; } cout << endl; return 0; }
[ "assignment.value.change", "identifier.change" ]
778,277
778,278
u906208439
cpp