text
stringlengths
49
983k
#include <bits/stdc++.h> using namespace std; const int N = 200005; int main() { int n, x, y; char num[N]; int step = 0; cin >> n >> x >> y; getchar(); gets(num); if (y == 0 && num[n - 1] == '0') step++; for (int i = 1; i <= y; i++) { if (num[n - i] == '1') step++; if (i == y && num[n - i - 1] == '0') step++; } for (int j = y + 2; j <= x; j++) { if (num[n - j] == '1') step++; } cout << step; }
#include <bits/stdc++.h> using namespace std; int main() { int n, x, y; cin >> n >> x >> y; string ss; cin >> ss; int countt = 0, countt1 = 0; for (int i = ss.size() - 1; x >= ss.size() - i; i--) { if (ss[i] == '1') countt1++; } cout << countt1 - (ss[ss.size() - y - 1] == '1' ? 1 : -1); return 0; }
#include <bits/stdc++.h> using namespace std; int main() { int t = 1; while (t--) { int n, x, y; cin >> n >> x >> y; string nn; cin >> nn; int ans = 0; for (int i = n - x; i < n; ++i) { if (i == n - y - 1) ans += nn[i] != '1'; else ans += nn[i] != '0'; } cout << ans << endl; } }
#include <bits/stdc++.h> using namespace std; const int MOD = 1000000007; const double PI = 4 * atan(1); const int MX = 100000; int t[300005]; int main() { int y, x, n; cin >> n >> y >> x; string second; cin >> second; int res = 0; for (int i = n - y; i < n; i++) { if (i == n - x - 1) res += (second[i] == '0'); else res += (second[i] == '1'); } cout << res; }
#include <bits/stdc++.h> using namespace std; long long const oo = 8e18; double const PI = acos(-1); int const ooi = 2e9; int const N = 1e5 + 100; int const M = 1e6 + 100; int const MOD = 998244353; int main() { int x, y, n; string s; cin >> n >> x >> y; cin >> s; reverse(s.begin(), s.end()); int cnt = 0; for (int i = 0; i < x; ++i) { if (i == y) continue; if (s[i] == '1') cnt++; } if (s[y] == '0') cnt++; cout << cnt << endl; return 0; }
#include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); int j, x, y; cin >> j >> x >> y; string n; cin >> n; string y1 = "1"; for (int i = 0; i < y; i++) y1 += '0'; int temp = x - y - 1; string temp1 = ""; while (temp--) temp1 += '0'; y1 = temp1 + y1; int count = 0; int k = 0; for (int i = j - x; i < j; i++) { if (n[i] != y1[k]) count++; k++; } cout << count << "\n"; return 0; }
#include <bits/stdc++.h> using namespace std; void input() {} int main() { ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL); input(); long long int n, x, y; cin >> n >> x >> y; string s; cin >> s; long long int idx = n - 1 - y; long long int cnt = 0; for (long long int i = n - x; i < n; i++) { if (i == idx) { if (s[i] == '0') cnt++; continue; } if (s[i] == '1') cnt++; } cout << cnt; return 0; }
#include <bits/stdc++.h> using namespace std; int main() { int n, x, y; cin >> n >> x >> y; string s; cin >> s; int count = 0; for (int i = n - 1; i >= (n - x); i--) { if (s[i] == '1' && i != n - y - 1) count++; if (s[i] == '0' && i == n - y - 1) count++; } cout << count; }
#include <bits/stdc++.h> using namespace std; int main() { string s; int n, a, b; cin >> n >> a >> b; cin >> s; int j = 0, cnt = 0; if (s[n - b - 1] != '1') cnt++; for (int i = n - 1; i >= n - a; i--) { j++; if (j == b + 1) continue; else { if (s[i] == '1') { cnt++; } } } cout << cnt << endl; return 0; }
#include <bits/stdc++.h> using namespace std; int main() { long long int x, y, n, i, count = 0, p; cin >> n >> x >> y; string ar; cin >> ar; for (i = n - 1; i > (n - x - 1); i--) { if (ar[i] == '1') { count++; } } p = n - y - 1; if (ar[p] == '0') count++; else count = count - 1; cout << count; return 0; }
#include <bits/stdc++.h> using namespace std; const int MAX_N = 1e5 + 5; void solve() {} int main() { ios_base::sync_with_stdio(0); cin.tie(0); int n, x, y, j = 0, ans = 0; string number; cin >> n >> x >> y; cin >> number; for (int i = n - 1; i >= n - x; i--) { if (j != y && number[i] == '1') ans++; if (j == y && number[i] == '0') ans++; j++; } cout << ans; return 0; }
#include <bits/stdc++.h> using namespace std; #pragma GCC optimize("Ofast") #pragma GCC optimize("unroll-loops") #pragma GCC target("sse2") void reverseStr(string& str) { int n = str.length(); for (int i = 0; i < n / 2; i++) swap(str[i], str[n - i - 1]); } void printval(long long n, long long total) { if (total == n) { for (int i = 0; i < n; ++i) { cout << 1 << " "; } } else if (total == 1) { cout << n << " "; } else if (total <= n / 2 + 1) { printval(n / 2, total - 1); printval(n / 2, 1); } else { printval(n / 2, n / 2); printval(n / 2, total - n / 2); } } long long mint(long long a, long long b) { if (a > b) return b; else return a; } long long gcd(long long a, long long b) { if (b == 0) return a; return gcd(b, a % b); } int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); std::cout.precision(15); string s; long long n, x, y; cin >> n >> x >> y; cin >> s; reverseStr(s); long long count = 0; for (int i = 0; i < x; i++) { if (i == y) { if (s[i] == '0') count++; } else { if (s[i] == '1') count++; } } cout << count; }
#include <bits/stdc++.h> using namespace std; int main() { long long n, x, y; string str; cin >> n >> x >> y >> str; reverse(str.begin(), str.end()); long long ans = 0; for (long long i = 0; i < x; i++) { if (str[i] == '1') ans++; if (i == y) { if (str[i] == '1') ans--; else ans++; } } cout << ans; return 0; }
#include <bits/stdc++.h> using namespace std; int main() { int n, x, y; scanf("%d", &n); scanf("%d", &x); scanf("%d", &y); string s; cin >> s; int cnt = 0; reverse(s.begin(), s.end()); for (int i = 0; i < y; i++) { if (s[i] != '0') cnt++; } if (s[y] != '1') cnt++; for (int i = y + 1; i < x; i++) { if (s[i] != '0') cnt++; } printf("%d\n", cnt); return 0; }
#include <bits/stdc++.h> using namespace std; const int inf = 2000000000; const long long infLL = 9000000000000000000; template <typename first, typename second> ostream& operator<<(ostream& os, const pair<first, second>& p) { return os << "(" << p.first << ", " << p.second << ")"; } template <typename T> ostream& operator<<(ostream& os, const vector<T>& v) { os << "{"; for (auto it = v.begin(); it != v.end(); ++it) { if (it != v.begin()) os << ", "; os << *it; } return os << "}"; } template <typename T> ostream& operator<<(ostream& os, const set<T>& v) { os << "["; for (auto it = v.begin(); it != v.end(); ++it) { if (it != v.begin()) os << ","; os << *it; } return os << "]"; } template <typename T> ostream& operator<<(ostream& os, const multiset<T>& v) { os << "["; for (auto it = v.begin(); it != v.end(); ++it) { if (it != v.begin()) os << ", "; os << *it; } return os << "]"; } template <typename first, typename second> ostream& operator<<(ostream& os, const map<first, second>& v) { os << "["; for (auto it = v.begin(); it != v.end(); ++it) { if (it != v.begin()) os << ", "; os << it->first << " = " << it->second; } return os << "]"; } void faltu() { cerr << '\n'; } template <typename T> void faltu(T a[], int n) { for (int i = 0; i < n; ++i) cerr << a[i] << ' '; cerr << '\n'; } template <typename T, typename... hello> void faltu(T arg, const hello&... rest) { cerr << arg << ' '; faltu(rest...); } int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); ; int n, x, y; cin >> n >> x >> y; string s; cin >> s; reverse(s.begin(), s.end()); int cnt = 0; for (int i = 0; i < x; ++i) { if (i == x || i == y) { if (s[i] == '0') ++cnt; } else { if (s[i] == '1') ++cnt; } } cout << cnt << '\n'; }
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); int n, x, y; cin >> n >> x >> y; string s; cin >> s; int ans = 0; for (int i = 1; i <= y + 1; i++) { if (i == y + 1) { if (s[n - i] == '0') ans++; } else { if (s[n - i] == '1') ans++; } } for (int i = y + 2; i <= x; i++) { if (s[n - i] == '1') ans++; } cout << ans << "\n"; }
#include <bits/stdc++.h> using namespace std; char str[200005]; int n, x, y, len, ans; int main() { scanf("%d%d%d%s", &n, &x, &y, str); len = strlen(str); for (int i = len - 1; i >= len - x; i--) { if (i == len - y - 1 && str[i] == '0') ans++; else if (i != len - y - 1 && str[i] == '1') ans++; } printf("%d\n", ans); }
#include <bits/stdc++.h> using namespace std; int main() { int n, x, y; cin >> n >> x >> y; string s; cin >> s; reverse(s.begin(), s.end()); int count = 0; for (int i = 0; i < x; i++) { if (s[i] == '1' && i != y) count++; } if (s[y] == '0') count++; cout << count; return 0; }
#include <bits/stdc++.h> using namespace std; int main() { int x, i, j, n, c = 0, y; cin >> n >> y >> x; string s; cin >> s; reverse(s.begin(), s.end()); for (i = 0; i <= y; i++) { if (i < x) { if (s[i] != '0') c++; } else if (i == x) { if (s[i] != '1') c++; } else if (i > x && i < y) { if (s[i] != '0') c++; } } cout << c << endl; return 0; }
#include <bits/stdc++.h> using namespace std; int main() { ios_base ::sync_with_stdio(0); cin.tie(0); int n, x, y; cin >> n >> x >> y; string a; cin >> a; reverse(a.begin(), a.end()); int solve = 0; for (int i = 0; i < y; ++i) { if (a[i] == '1') ++solve; } if (a[y] == '0') ++solve; for (int i = y + 1; i < x; ++i) { if (a[i] == '1') ++solve; } cout << solve << '\n'; }
#include <bits/stdc++.h> using namespace std; const int N = 2e5 + 5; int n, x, y; char s[N]; int main() { cin >> n >> x >> y; scanf("%s", s + 1); int cnt = 0, tot = 0, ans = 0; for (int i = n; i > n - x; i--) { if (cnt == y) { if (s[i] != '1') ans = 1; cnt++; continue; } if (s[i] == '1') tot++; cnt++; } cout << ans + tot; return 0; }
#include <bits/stdc++.h> using namespace std; const int maxn = 2e5 + 10; const int mod = 998244353; int a[maxn]; int main() { int n, x, y; cin >> n >> x >> y; string ss; cin >> ss; reverse(ss.begin(), ss.end()); int t = 0; for (int i = 0; i < x; i++) { if (i == y) { if (ss[i] == '0') t++; } else { if (ss[i] == '1') t++; } } cout << t << endl; }
#include <bits/stdc++.h> using namespace std; const double PI = acos(-1.0); const long long MOD = 1e9 + 7; const long long MAXN = 2e5 + 10; const int INF = 0x3f3f3f3f; const long long ll_INF = 9223372036854775807; long long qm(long long a, long long b) { long long ret = 1; while (b) { if (b & 1) ret = ret * a % MOD; a = a * a % MOD; b >>= 1; } return ret; } long long gcd(long long a, long long b) { return b ? gcd(b, a % b) : a; } long long lcm(long long a, long long b) { return (a * b) / gcd(a, b); } int n, x, y; char s[MAXN]; int main() { scanf("%d%d%d", &n, &x, &y); getchar(); scanf("%s", s + 1); int ans = 0; for (int i = n; i > n - x; i--) { if (i != (n - y) && i != (n - x)) { if (s[i] == '1') ans++; } else { if (s[i] != '1') ans++; } } printf("%d", ans); return 0; }
#include <bits/stdc++.h> using namespace std; int main() { long long int n, x, y; string a; cin >> n >> x >> y >> a; char b[n]; long long int i = 0; for (long long int j = a.length() - 1; j >= 0; j--) { b[i] = a[j]; i++; } long long int no = 0; for (long long int i = x - 1; i >= 0; i--) { if (i > y) { if (b[i] == '1') { no++; } } else if (i == y) { if (b[i] == '0') { no++; } } else { if (b[i] == '1') { no++; } } } cout << no << endl; }
#include <bits/stdc++.h> using namespace std; int main() { int n, x, y, ans = 0; cin >> n >> x >> y; string s, t; cin >> s; t = s; int i = n - 1; while (x--) { s[i] = '0'; i--; } s[n - 1 - y] = '1'; for (int i = 0; i < n; i++) { if (t[i] != s[i]) { ans++; } } cout << ans; return 0; }
#include <bits/stdc++.h> using namespace std; int main() { long long int n1, ans1 = 0, d, i = 0, x, y; char n[200010]; cin >> n1 >> x >> y; cin >> n; for (int i = n1 - 1; i >= n1 - x; i--) if (n[i] == '1' && i != n1 - y - 1) ans1++; if (n[n1 - y - 1] == '0') ans1++; cout << ans1; return 0; }
#include <bits/stdc++.h> using namespace std; int n, x, y, k; string a; int main() { cin >> n >> x >> y; cin >> a; for (int i = 0; i < y; i++) if (a[n - i - 1] != '0') { k++; } if (a[n - y - 1] != '1') { k++; } for (int i = 0; i < x - y - 1; i++) if (a[n - y - 2 - i] == '1') { k++; } cout << k; return 0; }
#include <bits/stdc++.h> using namespace std; int main() { int n, x, y; string s; cin >> n >> x >> y >> s; int ans = 0; for (int i = n - 1; i >= n - x; i--) { if (s[i] == '1') { ans++; } } if (s[n - 1 - y] == '0') { ans++; } else { ans--; } cout << ans << "\n"; }
#include <bits/stdc++.h> using namespace std; int main() { int a, b, c, d = 0; cin >> a >> b >> c; string str; cin >> str; if (str[a - c - 1] != '1') d++; for (int i = a - b; i < a; i++) { if (str[i] != '0' && i != a - c - 1) d++; } cout << d << endl; return 0; }
#include <bits/stdc++.h> using namespace std; int main(void) { char A[250000]; char B[250000]; int n, x, y, i; int count = 0; cin >> n >> x >> y; for (i = 0; i < n; i++) scanf(" %c", &A[i]); for (i = n - 1; i >= 0; i--) B[(n - 1) - i] = A[i]; for (i = 0; i < x; i++) { if (i == y) { if (B[i] == '0') count++; } else { if (B[i] == '1') count++; } } cout << count; }
#include <bits/stdc++.h> using namespace std; signed main() { ios_base ::sync_with_stdio(false); cin.tie(0); cout.tie(0); int n, x, y; string s; cin >> n >> x >> y >> s; int cnt = 0; for (int i = 1; i <= x; ++i) { if (i == y + 1) cnt += 1 - (s[n - i] - '0'); else cnt += s[n - i] - '0'; } cout << cnt << '\n'; return 0; }
#include <bits/stdc++.h> using namespace std; int main() { long long n, m, k; cin >> n >> m >> k; string sn; cin >> sn; string sk; sk = ""; for (long long i = 0; i < m - k - 1; ++i) sk += '0'; sk += '1'; for (long long i = 0; i < k; ++i) sk += '0'; long long cnt = 0; for (long long i = 0; i < m; ++i) { if (sn[sn.length() - m + i] != sk[i]) ++cnt; } cout << cnt; }
#include <bits/stdc++.h> using namespace std; const int MOD = 1e9 + 7; long long gcd(long long a, long long b) { if (b == 0) return a; return gcd(b, a % b); } int main() { ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); ; long long n, x, y; cin >> n >> x >> y; string s; cin >> s; long long ans = 0; long long i = n - 1; long long c = 0; if (s[n - y - 1] == '0') ans++; for (int i = n - x; i < n; i++) { if (i == n - y - 1) continue; else if (s[i] == '1') ans++; } cout << ans << endl; }
#include <bits/stdc++.h> using namespace std; int main() { int n, x, y; while (scanf("%d %d %d", &n, &x, &y) == 3) { string s; cin >> s; int l = s.length(); int p = x, q = y, j = 0; for (int i = l - 1; i >= 0 && p--; i--) { if (s[i] == '1') j++; } if (s[l - y - 1] == '1') j--; else j++; cout << j << endl; } }
#include <bits/stdc++.h> using namespace std; char ch[200005]; int main() { int n, x, y; cin >> n >> x >> y; cin >> ch; int ans = 0; for (int i = n - 1; i >= (n - y); i--) { if (ch[i] - '0') ans++; } if (!(ch[n - y - 1] - '0')) ans++; for (int i = n - y - 2; i >= (n - x); i--) { if ((ch[i] - '0')) ans++; } cout << ans << endl; return 0; }
#include <bits/stdc++.h> using namespace std; int main() { int x, y, n, cnt = 0; string s; cin >> n >> x >> y; cin >> s; reverse(s.begin(), s.end()); string temp = s.substr(0, x); for (int i = 0; i < temp.size(); i++) { if (i == y) { if (temp[i] == '0') cnt++; } else { if (temp[i] == '1') cnt++; } } cout << cnt << "\n"; return 0; }
#include <bits/stdc++.h> int main() { int n, x, y; scanf("%d %d %d", &n, &x, &y); char num[n]; scanf("%s", num); int j = n, cnt = 0; for (int i = 0; i < x; i++) { if (j == n - y) { if (num[j - 1] == '1') { } else { cnt++; } } else if (j > n - x) { if (num[j - 1] == '1') { cnt++; } } j--; } printf("%d\n", cnt); }
#include <bits/stdc++.h> using namespace std; int main() { int n, x, y; cin >> n >> x >> y; string s; cin >> s; string s1; for (int i = 0; i < x + 1; i++) { if ((x - i - 1) == y) s1 += '1'; else s1 += '0'; } int l = 0; int j = 0; for (int i = s.size() - x; i < s.size(); i++) { if (s1[j] != s[i]) l++; j++; } cout << l; }
#include <bits/stdc++.h> using namespace std; int main() { int x, y, n; string inp, str; cin >> n >> x >> y; cin >> inp; str = inp; int i; for (i = n - 1; i >= n - y; --i) { str[i] = '0'; } str[i--] = '1'; for (; i >= n - x; --i) { str[i] = '0'; } int count = 0; for (int i = 0; i < n; ++i) { if (str[i] != inp[i]) count++; } cout << count << endl; return 0; }
#include <bits/stdc++.h> using namespace std; void input(int n, int a[]) { for (int i = 0; i < n; ++i) cin >> a[i]; } long long bin_expo(long long A, long long B, long long M) { long long res = 1LL; while (B > 0) { if (B % 2 == 1) { res = (res * A) % M; } A = (A * A) % M; B = B / 2; } return res; } int main() { long long n, x, y; cin >> n >> x >> y; string s; cin >> s; int ind = s.length() - 1; int cnt = 0; for (int i = 0; i < y; i++) { if (s[ind] == '1') { cnt++; s[ind] = '0'; } ind--; } if (s[ind] == '0') { cnt++; s[ind] = '1'; } int cc = 0; int idx = s.length() - 1; for (int i = 0; i < x; i++) { if (s[idx] == '1' && idx < ind) cc++; idx--; } cout << cc + cnt << endl; return 0; }
#include <bits/stdc++.h> int main() { int n, h, m, i, j, k, count = 0; scanf("%d %d %d", &n, &m, &h); getchar(); char c[200009]; for (i = 0; i < n; i++) scanf("%c", &c[i]); j = n - 1 - h; k = n - 1 - m; for (i = n - 1; i >= k; i--) { if (i == j && c[i] == '0') count++; else if (c[i] == '1' && i != j && i != k) count++; } printf("%d", count); }
#include <bits/stdc++.h> using namespace std; bool isodd(unsigned long long int x) { return x & 1; } bool iseven(unsigned long long int x) { return !(x & 1); } int main() { ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); int n, a, b; string s; cin >> n >> a >> b >> s; int ans = 0; int num1 = s[n - 1 - a] - '0'; for (int x = n - a; x < s.size(); x++) { int num = s[x] - '0'; if (x == n - 1 - b) { if (num == 0) ans++; } else { if (num == 1) ans++; } } cout << ans << "\n"; return 0; }
#include <bits/stdc++.h> using namespace std; int main() { long long n, x, y, ans = 0; cin >> n >> x >> y; string a; cin >> a; for (int i = n - 1; i >= 0; i--) { if (n - i - 1 < y) { if (a[i] != '0') ans++; } else if (n - i - 1 == y) { if (a[i] != '1') ans++; } else if (n - i - 1 < x) { if (a[i] != '0') ans++; } else break; } cout << ans; return 0; }
#include <bits/stdc++.h> using namespace std; int main() { int n, x, y, i, j, count = 0, time_x = 0, time_y = 0; char str[200001], chr[200001]; cin >> n >> x >> y; getchar(); for (i = 0; i < n; i++) { cin >> str[i]; } for (i = 0; i < x; i++) { if (i != y) chr[i] = '0'; else chr[i] = '1'; } for (i = n - 1, j = 0; j < x && i >= 0; j++, i--) { if (chr[j] != str[i]) count++; } cout << count << endl; return 0; }
#include <bits/stdc++.h> using namespace std; char a[200005]; int main() { int y, x, n, ans = 0; cin >> n >> x >> y; cin >> a; for (int i = n - 1; i >= n - 1 - x; i--) { if (i == n - 1 - y && a[i] == '0') ans++; else if (a[i] == '1' && i != n - 1 - y && i != n - 1 - x) ans++; } cout << ans << endl; return 0; }
#include <bits/stdc++.h> using namespace std; int main() { long long int n, x, y, i, k, sum = 0; string s; cin >> n >> x >> y; cin >> s; long long int a[x], b[y + 1]; for (i = 0; i < x; i++) { a[i] = s[n - 1 - i] - 48; ; } for (i = 0; i <= y; i++) { if (i != y) b[i] = 0; else b[i] = 1; } for (i = 0; i <= y; i++) { if (a[i] != b[i]) sum++; } for (i = y + 1; i < x; i++) { if (a[i] != 0) sum++; } cout << sum; }
#include <bits/stdc++.h> using namespace std; const long long MOD = 1000 * 1000 * 1000 + 7; const long long INF = 1ll * 1000 * 1000 * 1000 * 1000 * 1000 * 1000 + 7; const long long MOD2 = 998244353; const long long N = 5000 * 100 + 1; const long long N2 = 1000 * 1000 + 5; const long double PI = 3.14159265; const long long R = 250; long long gcd(long long a, long long b) { if (!b) return a; return gcd(b, a % b); } long long power(long long x, long long y, long long p) { long long res = 1; x %= p; while (y > 0) { if (y & 1) res = (res * x) % p; y = y >> 1; x = (x * x) % p; } return res; } bool sortbysec(const pair<long long, long long> &a, const pair<long long, long long> &b) { return (a.second < b.second); } signed main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); long long n, x, y; long long count = 0; cin >> n >> x >> y; string s; cin >> s; long long c = 0; for (long long i = s.length() - 1; i >= 0; i--) { if (c < x && s[i] == '1' && c != y) { count++; } if (c == y && s[i] == '0') { count++; } c++; } cout << count << "\n"; return 0; }
#include <bits/stdc++.h> using namespace std; mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); void c_p_c() {} bool f(long long x, long long y) { return x > y; } int32_t main() { c_p_c(); ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); long long n, x, y; cin >> n >> x >> y; string s; cin >> s; long long l = s.size(); long long c = 0; for (long long i = n - x; i < n; i++) { if (i == n - y - 1) c += (s[i] != '1'); else { c += (s[i] != '0'); } } cout << c; }
#include <bits/stdc++.h> using namespace std; int main() { long n, x, y; char s[200010]; cin >> n >> x >> y; cin.ignore(); cin.getline(s, 200010); long front_zeros = 0; long back_zeros = 0; long zeros = 0; for (long i = n - x; i < n; i++) { if (s[i] == '0' && i == n - y - 1) { zeros++; } else if (s[i] == '1' && i == n - y - 1) { } else if (s[i] == '1') { zeros++; } } cout << zeros << "\n"; return 0; }
#include <bits/stdc++.h> using namespace std; int N, M; int h = 101; void google() { int n, x, y, count = 0; cin >> n >> x >> y; string str; cin >> str; int j; for (int i = n - 1; i >= 0; i--) { j = (n - 1) - i; if (j == y && str[i] == '0') count++; else if (j < y && str[i] == '1') count++; else if (j > y && j < x && str[i] == '1') count++; } cout << count << "\n"; } int solve() { int n; cin >> n; int a[n + 1]; int count = 0; for (long long int i = 1; i < n + 1; i++) cin >> a[i]; sort(a + 1, a + n + 1); int j = 1; for (long long int i = 1; i < n + 1; i++) { if (j <= a[i]) count++, j++; } cout << count << "\n"; } void solve3() { int n; cin >> n; string s; cin >> s; int j; if (n % 2 == 0) { for (long long int i = 1; i < n - 1; i++) { j = i - 1; if (s[j] == s[j + 1] && j % 2 == 0) { if (s[j + 1] == s[j + 2]) ; } } } } int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); int t = 1; while (t--) { google(); } return 0; }
#include <bits/stdc++.h> long long A, B, C, D, E, F, I, J, K, M, N, O, P, Q, R, S, T, U, V, X, Y, Z; using namespace std; const string MINUSINF = "-"; template <class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; } void chmax(string& a, string b) { if (a == MINUSINF) a = b; else if (a.size() < b.size()) a = b; else if (a.size() == b.size()) { if (a < b) a = b; } } template <class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; } int GCD(int a, int b) { return b ? GCD(b, a % b) : a; } stack<long long> sta; queue<long long> que; deque<long long> dque; set<string> s_set; long long sum, sum1, sum2, sum3, sum4; long long flg, flg1, flg2, flg3, cnt, cnt1, cnt2, cnt3, cnt4; long long wk, wk1, wk2, wk3, wk4; long long ans; bool f; long long weight[110], value[110]; long long a[100010][3]; long long n, h[100005]; vector<long long> p, c; int vis[200001]; vector<string> first; int Left[2100][2100], Right[2100][2100], Up[2100][2100], Down[2100][2100]; long long match[10] = {2, 5, 5, 4, 5, 6, 3, 7, 6}; vector<long long> box; int main() { cin.tie(nullptr); ios::sync_with_stdio(false); long long max, max1; long long min, min1; sum = sum1 = sum2 = sum3 = sum4 = 0; flg = flg1 = flg2 = flg3 = cnt = cnt1 = cnt2 = cnt3 = cnt4 = 0; max = max1 = 0; wk = wk1 = wk2 = wk3 = wk4 = 0; ans = 0; min = min1 = 1e18 + 5; std::cin >> N >> X >> Y; string s, t; std::cin >> s; for (long long i = s.length() - 1; i >= s.length() - 1 - X + 1; i--) { if (cnt == Y) { if (s[i] == '0') { ans++; } } else { if (s[i] == '1') { ans++; } } cnt++; } if (1) { printf("%lld", ans); } else { } return 0; return 0; }
#include <bits/stdc++.h> using namespace std; const long long sz = 1e6 + 5; int main() { string s; int n, x, y; cin >> n >> x >> y; cin >> s; reverse(s.begin(), s.end()); int ans = 0; for (int i = 0; i < x; i++) { if (i == y) continue; if (s[i] == '1') ans++; } if (s[y] == '0') ans++; cout << ans; }
#include <bits/stdc++.h> using namespace std; void start() {} void sober() { long long int n, x, y; cin >> n >> y >> x; string s; cin >> s; long long int count = 0; for (int i = n - 1; i != n - y - 1; i--) { if (i == n - 1 - x) { if (s[i] == '0') count++; } else if (s[i] == '1') { count++; } } cout << count << "\n"; } int main() { start(); int t = 1; while (t--) sober(); }
#include <bits/stdc++.h> using namespace std; void __print(int x) { cerr << x; }; void __print(long x) { cerr << x; }; void __print(long long x) { cerr << x; }; void __print(unsigned x) { cerr << x; }; void __print(unsigned long x) { cerr << x; }; void __print(unsigned long long x) { cerr << x; }; void __print(float x) { cerr << x; }; void __print(double x) { cerr << x; }; void __print(long double x) { cerr << x; }; void __print(char x) { cerr << '\'' << x << '\''; }; void __print(const char *x) { cerr << '\"' << x << '\"'; }; void __print(const string &x) { cerr << '\"' << x << '\"'; }; void __print(bool x) { cerr << (x ? "true" : "false"); } long long powmod(long long a, long long b) { long long res = 1; a %= 1000000007; assert(b >= 0); for (; b; b >>= 1) { if (b & 1) res = res * a % 1000000007; a = a * a % 1000000007; } return res; } long long string_to_int(string s) { long long ans = 0; long long p = 1; for (long long i = s.size() - 1; i >= 0; i--) { ans += (s[i] - '0') * p; p *= 10; } return ans; } long long fast_pow(long long a, long long b) { if (b == 1) return a; if (b == 0) return 1; long long x = fast_pow(a, b / 2); x *= x; if (b & 1) x *= a; return x; } template <typename T, typename V> void __print(const pair<T, V> &x) { cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}'; } template <typename T> void __print(const T &x) { long long f = 0; cerr << '{'; for (auto &i : x) cerr << (f++ ? "," : ""), __print(i); cerr << "}"; } void _print() { cerr << "]\n"; } template <typename T, typename... V> void _print(T t, V... v) { __print(t); if (sizeof...(v)) cerr << ", "; _print(v...); } void t_c_c() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); long long n, x, y; cin >> n >> x >> y; string s; cin >> s; long long ans = 0; for (long long i = n - 1; i >= n - x; i--) { if (s[i] == '1') { ans++; } } if (s[n - y - 1] == '1') { ans--; } if (s[n - y - 1] == '0') { ans++; } cout << ans << '\n'; } int32_t main() { t_c_c(); return 0; }
#include <bits/stdc++.h> using namespace std; int main() { int n, x, y, c = 0; cin >> n >> x >> y; string a; cin >> a; for (int i = n - x; i < n; i++) { if (a[i] != '0') c++; } if (a[n - 1 - y] == '1') cout << c - 1; else cout << c + 1; return 0; }
#include <bits/stdc++.h> using namespace std; using ll = long long; using dd = double; const int N = (int)1e6 + 7; int a[N]; vector<int> foo; void help() {} void TaoCode() { int n, x, y; cin >> n >> x >> y; string bit; cin >> bit; int cnt = 0; for (int i = (0); i < (x); i++) { if (i == y and bit[(int)bit.size() - i - 1] == '0') { cnt++; } else if (i != y and bit[(int)bit.size() - i - 1] == '1') { cnt++; } } cout << cnt; } int main() { ios::sync_with_stdio(false), cin.tie(0), cout.tie(0); TaoCode(); return 0; }
#include <bits/stdc++.h> using namespace std; int main(void) { std::ios::sync_with_stdio(false); cin.tie(0); string s; int n, x, y; cin >> n >> x >> y; cin >> s; int ans = 0; for (int i = n - 1; i >= n - x; --i) { if (i >= n - y && s[i] == '1') ans++; else if (i < n - y - 1 && s[i] == '1') { ans++; } } if (s[n - y - 1] == '0') ans++; cout << ans; return 0; }
#include <bits/stdc++.h> using namespace std; int main() { int n, x, y; string s; cin >> n >> x >> y >> s; int ans = 0; for (int i = n - x; i < n; ++i) { if (i == n - y - 1) ans += s[i] != '1'; else ans += s[i] != '0'; } cout << ans << endl; return 0; }
#include <bits/stdc++.h> using namespace std; long long t, n, x, y, m, k, a[100005], b[100005]; int main() { ios_base::sync_with_stdio(0); cin.tie(0); cin >> n >> x >> y; string s; cin >> s; int ans = 0; int cnt = 1; for (int i = n - 1; cnt <= x; i--, cnt++) { if (cnt == y + 1) { if (s[i] == '0') ans++; } else if (s[i] == '1') ans++; } cout << ans; return 0; }
#include <bits/stdc++.h> using namespace std; int main() { long long n, x, y, i, cnt = 0; string s; cin >> n >> x >> y; cin >> s; reverse(s.begin(), s.end()); i = 0; while (i < x) { if (i == y && s[i] != '1') cnt++; else if (i != y && s[i] != '0') cnt++; i++; } cout << cnt << "\n"; }
#include <bits/stdc++.h> using namespace std; int main() { long long int t; t = 1; while (t--) { long long int n, x, y; cin >> n >> x >> y; long long int ar[n + 4]; string s; cin >> s; for (long long int i = 0; i < n; i++) { ar[i] = s[i] - '0'; } long long int i = 0, count = 0; while (i < y) { if (ar[n - 1 - i]) count++; i++; } if (!ar[n - 1 - i]) count++; i = y + 1; while (i < x) { if (ar[n - 1 - i]) count++; i++; } cout << count << endl; } }
#include <bits/stdc++.h> int main() { std::ios_base::sync_with_stdio(false); long n, x, y; std::cin >> n >> x >> y; char c; while (n > x) { --n; std::cin >> c; } long ans = 0; while (n > 0) { --n; std::cin >> c; if ((y < n && c != '0') || (y == n && c == '0') || (y > n && c != '0')) ++ans; } std::cout << ans << std::endl; }
#include <bits/stdc++.h> using namespace std; using namespace std; int main() { int n, m, p; cin >> n >> m >> p; string a; cin >> a; long long c = 0; int x = 0; for (int i = n - p; i < n; i++) { if (x == p) break; x++; if (a[i] == '1') c++; } if (a[n - p - 1] == '0') c++; x = 0; int y = m - p - 1; for (int i = n - m; i < n; i++) { if (x == y) break; x++; if (a[i] == '1') c++; } cout << c << endl; }
#include <bits/stdc++.h> using namespace std; int main() { int n, x, y; cin >> n >> x >> y; string str; cin >> str; int cnt = 0; for (int i = n - x; i < n; i++) { if (i == n - y - 1) { if (str[i] != '1') cnt++; } else { if (str[i] == '1') cnt++; } } cout << cnt << endl; return 0; }
#include <bits/stdc++.h> using namespace std; const int maxn = 2e5 + 10; int a[maxn]; char s[maxn]; int main() { int n, x, y; while (scanf("%d%d%d", &n, &x, &y) != EOF) { scanf("%s", s); int ans = 0, cnt = 0; for (int i = n - 1; i >= 0; i--) { if (cnt >= x) break; else if (cnt == y) { if (s[i] != '1') ans++; } else { if (s[i] == '1') ans++; } cnt++; } printf("%d\n", ans); } return 0; }
#include <bits/stdc++.h> using namespace std; const int N = 1e5 + 10; int main() { int n, x, y, ans = 0; cin >> n >> x >> y; string s; cin >> s; for (int i = n - x; i < n; i++) { if (i == n - 1 - y) { if (s[i] != '1') ans++; } else { if (s[i] != '0') ans++; } } cout << ans; return 0; }
#include <bits/stdc++.h> using namespace std; int main() { long long a, b, x, y, n1; string s; cin >> n1 >> x >> y; cin >> s; reverse(s.begin(), s.end()); int c = count(s.begin(), s.begin() + x, '1'); c -= (s[y] == '1'); c += (s[y] == '0'); cout << c; return 0; }
#include <bits/stdc++.h> using namespace std; int main() { long long n, x, y, z, t, i, j, l, k, s1, asdfghj, m; long long a[123456]; long long b[123456]; string s; t = 0; cin >> n >> m >> k; cin >> s; for (i = n - m; i <= n - k - 2; i++) { if (s[i] == 49) t++; } if (s[n - k - 1] == 48) t++; for (i = n - k; i <= n - 1; i++) { if (s[i] == 49) t++; } cout << t; }
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); int n, x, y; cin >> n >> x >> y; bool num[n + 1]; string s; cin >> s; for (int i = s.length() - 1; i >= 0; i--) { if (s[i] == '1') num[n - i] = 1; else num[n - i] = 0; } int ans = 0; for (int i = 1; i <= x; i++) { if (num[i]) ans++; } if (num[y + 1]) ans--; else ans++; cout << ans; return 0; }
#include <bits/stdc++.h> using namespace std; int main() { int n, x, y, c = 0; cin >> n >> x >> y; string mas; cin >> mas; for (int i = n - x; i < n; i++) { if (i == n - y - 1) { if (mas[i] == '0') { mas[i] = '1'; c++; } } else { if (mas[i] == '1') { mas[i] = '0'; c++; } } } cout << c; return 0; }
#include <bits/stdc++.h> using namespace std; int main() { int n, x, y; cin >> n >> x >> y; string s; cin >> s; int count = 0; for (int i = 0; i < x; i++) { int j = n - 1 - i; if (i == y && s[j] != '1') { count++; } if (i != y && s[j] != '0') { count++; } } cout << count << endl; return 0; }
#include <bits/stdc++.h> using namespace std; template <class A, class B> ostream &operator<<(ostream &out, const pair<A, B> &a) { return out << "(" << a.first << "," << a.second << ")"; } template <class A> ostream &operator<<(ostream &out, const vector<A> &a) { for (const A &it : a) out << it << " "; return out; } template <class A, class B> istream &operator>>(istream &in, pair<A, B> &a) { return in >> a.first >> a.second; } template <class A> istream &operator>>(istream &in, vector<A> &a) { for (A &i : a) in >> i; return in; } signed main() { ios_base::sync_with_stdio(0); cin.tie(0); long long n, x, y; cin >> n >> x >> y; string s; cin >> s; reverse((s).begin(), (s).end()); long long cnt = 0; for (long long i = 0; i < x; i++) { if ((i == x || i == y)) { cnt += s[i] == '0'; } else cnt += s[i] == '1'; } cout << cnt; }
#include <bits/stdc++.h> using namespace std; int main() { int *n = new int, x, y; cin >> *n >> x >> y; delete n; n = nullptr; string str; cin >> str; int count = 0; if (str[str.length() - y - 1] == '0') { str[str.length() - y - 1] = '1'; count++; } for (int i = str.length() - x; i < str.length(); i++) { if (str[i] == '1' && i != str.length() - y - 1) { str[i] = '0'; count++; } } cout << count; return 0; }
#include <bits/stdc++.h> using namespace std; int main(int argc, char const *argv[]) { int n, x, y; cin >> n >> x >> y; string s; cin >> s; string res = s; for (int i = n - 1; i >= n - x; --i) { res[i] = '0'; } res[n - y - 1] = '1'; int ans = 0; for (int i = n - 1; i >= n - x; --i) { if (res[i] != s[i]) ans++; } cout << ans << endl; return 0; }
#include <bits/stdc++.h> using namespace std; long long dp[100010], a[500010], pre[100010]; bool vis[100010]; int main() { long long n, x, y; cin >> n >> x >> y; string s; cin >> s; long long c = 0; for (long long i = s.length() - 1; i >= s.size() - y; i--) { if (s[i] != '0') c++; } if (s[s.size() - y - 1] != '1') c++; for (long long i = s.size() - 2 - y; i >= s.size() - x; i--) { if (s[i] != '0') c++; } cout << c; return 0; }
#include <bits/stdc++.h> using namespace std; int main() { long long int n, x, y; scanf("%lld", &n); scanf("%lld", &x); scanf("%lld", &y); string str, temp; cin >> str; temp = str; long long int i = n - 1; while (x--) { temp[i] = '0'; i--; } i = n - 1; while (y--) { temp[i] = '0'; i--; } temp[i] = '1'; long long int ans = 0; for (long long int i = 0; i < n; i++) ans += (str[i] != temp[i]); printf("%lld\n", ans); return 0; }
#include <bits/stdc++.h> using namespace std; bool Check(int N, int pos) { return (bool)(N & (1 << pos)); } int Set(int N, int pos) { return N = N | (1 << pos); } int fx[] = {+0, +0, +1, -1, -1, +1, -1, +1}; int fy[] = {-1, +1, +0, +0, +1, +1, -1, -1}; int hr[] = {-2, -2, -1, +1, +2, +2, -1, +1}; int hc[] = {+1, -1, +2, +2, -1, +1, -2, -2}; int dx[] = {+1, -1, +0, +0}; int dy[] = {+0, +0, +1, -1}; const int MAXN = (int)1e5 + 9; int main() { int i, j, k, l, m, n, p, q, x, y, u, v, r, tc, t; string s; cin >> n >> x >> y; cin >> s; string ss = ""; for (i = n - 1, j = 0; j < x; i--, j++) ss += s[i]; reverse(ss.begin(), ss.end()); string rem = "1"; for (i = 0; i < y; i++) rem += "0"; int cnt = 0; for (i = ss.size() - 1, j = rem.size() - 1; j >= 0; i--, j--) { if (ss[i] == rem[j]) continue; else cnt++; } for (; i >= 0; i--) { if (ss[i] == '1') cnt++; } cout << cnt << endl; return 0; }
#include <bits/stdc++.h> using namespace std; int main() { int n, x, y; cin >> n >> x >> y; string check = "1"; for (int i = 0; i < y; i++) { check += '0'; } string s; cin >> s; string a = s.substr(n - x - 1, x + 1); int cont = 0; for (int i = 0; i < x - y; i++) { if (a[i] != '0' && i != 0) cont++; } int j = 0; for (int i = x - y; i < x + 1; i++) { cont += (check[j] != a[i]); j++; } cout << cont << endl; }
#include <bits/stdc++.h> using namespace std; const int inf = 1e9 + 7; const long long INF = 1e18 + 7; void solve() { int n, x, y; cin >> n >> x >> y; string s; cin >> s; string res; for (int i = 0; i < x; i++) { if (i == y) res += '1'; else res += '0'; } int ans = 0; for (int i = n - 1; i >= n - x; i--) { if (s[i] != res[n - 1 - i]) ans++; } cout << ans; } int main() { ios_base::sync_with_stdio(0); cin.tie(0); int tt; tt = 1; while (tt--) { solve(); cout << '\n'; } }
#include <bits/stdc++.h> using namespace std; int main() { int n, x, y; string s; cin >> n >> x >> y >> s; int ans = 0; for (int i = s.size() - x; i < s.size(); ++i) { if (i == s.size() - y - 1) { if (s[i] == '0') ++ans; } else { if (s[i] == '1') ++ans; } } cout << ans << '\n'; }
#include <bits/stdc++.h> using namespace std; int main() { long long a, n, m, l = 0; string s; cin >> a >> n >> m >> s; for (int i = a - 1; i >= a - n; i--) if (s[i] == '1' && i != a - m - 1) l++; if (s[a - m - 1] == '0') l++; cout << l; }
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); long long x, y, i, c = 0, p, j; string n; cin >> p >> x >> y >> n; i = p - 1; y = p - 1 - y; for (j = 0; j < x; j++) { if (i == y) { if (n[i] == '0') { n[i] = '1'; c++; } } else if (i != y) { if (n[i] == '1') { n[i] = '0'; c++; } } i--; } cout << c; return 0; }
#include <bits/stdc++.h> using namespace std; template <class T> inline T bigMod(T p, T e, T M) { long long ret = 1; for (; e > 0; e >>= 1) { if (e & 1) ret = (ret * p) % M; p = (p * p) % M; } return (T)ret; } template <class T> inline T modInverse(T a, T M) { return bigMod(a, M - 2, M); } template <class T> inline T gcd(T a, T b) { if (b == 0) return a; return gcd(b, a % b); } template <class T> inline T lcm(T a, T b) { a = abs(a); b = abs(b); return (a / gcd(a, b)) * b; } template <class T> inline T diss(T x1, T x2, T y1, T y2) { return sqrt(((x1 - x2) * (x1 - x2)) + ((y1 - y2) * (y1 - y2))); } template <class T> inline string int2String(T a) { ostringstream str; str << a; return str.str(); } template <class T> inline T string2int(string a) { stringstream str(a); T b; str >> b; return b; } const int dr[] = {0, 1, 0, -1, -1, 1, 1, -1, -2, -2, 2, 2, -1, -1, 1, 1}; const int dc[] = {1, 0, -1, 0, 1, 1, -1, -1, -1, 1, -1, 1, -2, 2, -2, 2}; bool sortbysec(const pair<long long, long long> &a, const pair<long long, long long> &b) { return (a.second < b.second); } long long floorSqrt(long long x) { if (x == 0 || x == 1) return x; long long start = 1, end = x, ans; while (start <= end) { long long mid = (start + end) / 2; if (mid * mid == x) return mid; if (mid * mid < x) { start = mid + 1; ans = mid; } else end = mid - 1; } return ans; } bool is_prime(long long n) { if (n == 1) return false; long long anp = sqrt(n); for (long long i = 2; i <= anp; i++) if (n % i == 0) return false; return true; } long long factorials(int n) { if (!n) return 1; return n * factorials(n - 1); } long long dig_sum(long long x) { long long sm = 0; while (x) { sm += (x % 10); x /= 10; } return sm; } int main() { long long n, x, y; scanf("%lld %lld %lld", &n, &x, &y); string s; cin >> s; int ans = 0; if (s[n - y - 1] == '1') ans--; else if (s[n - y - 1] == '0') ans++; for (int i = n - 1, j = 0; j < x; i--, j++) { if (s[i] == '1') ans++; } cout << ans << endl; return 0; }
#include <bits/stdc++.h> using namespace std; signed main() { ios::sync_with_stdio(false); cin.tie(0); long long n, x, y; cin >> n >> x >> y; string s; cin >> s; long long zero = 0, one = 0; for (long long i = 0; i < n; i++) { if (s[i] == '1') one++; else zero++; } string ans = ""; for (long long i = 0; i < y; i++) ans += '0'; ans = '1' + ans; for (long long i = 1; i <= (x - y - 1); i++) ans = '0' + ans; long long cnt = 0; long long j = 0; for (long long i = n - x; i < n; i++) { if (s[i] != ans[j]) cnt++; j++; } cout << cnt << '\n'; }
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); ; int n, x, y, count = 0; string ans, pos; cin >> n >> x >> y >> ans; for (int i = 0; i < x; i++) { if (i == x - y - 1) pos += '1'; else pos += '0'; } for (int i = ans.size() - x, j = 0; i < ans.size(); i++, j++) if (ans[i] != pos[j]) count++; cout << count << endl; }
#include <bits/stdc++.h> int main() { int x, n, y, t = 0; scanf("%d %d %d\n", &n, &x, &y); char p; int a[n]; for (int i = 0; i < n; i++) { scanf("%c", &p); a[i] = (int)p - '0'; } for (int i = (n - 1); i >= (n - x); i--) { if ((i == (n - y - 1))) { if (a[i] != 1) { t++; } continue; } if (a[i]) { t++; } } printf("%d\n", t); return 0; }
#include <bits/stdc++.h> using namespace std; int main() { int n, x, y, i; cin >> n >> y >> x; string s; cin >> s; int k = y; int count = 0; for (i = n - 1; k > 0; i--) { if (s[i] == '1' && n - i != x + 1) count++; if (s[i] == '0' && n - i == x + 1) count++; k--; } if (s[i] == 0) count++; cout << count << endl; }
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); string n; int x = 0, y = 0, l = 0, i = 0, c = 0; cin >> l >> x >> y; cin >> n; for (i = (l - x); i < (l - y - 1); ++i) { if (n[i] == '1') { ++c; n[i] = '0'; } } if (n[l - y - 1] == '0') { ++c; n[l - y - 1] = '1'; } for (i = (l - y); i < l; ++i) { if (n[i] == '1') { ++c; n[i] = '0'; } } cout << c << endl; }
#include <bits/stdc++.h> template <typename _Tp> _Tp gcd(const _Tp &a, const _Tp &b) { return (!b) ? a : gcd(b, a % b); } template <typename _Tp> __inline__ __attribute__((always_inline)) _Tp abs(const _Tp &a) { return a > 0 ? a : -a; } template <typename _Tp> __inline__ __attribute__((always_inline)) _Tp max(const _Tp &a, const _Tp &b) { return a < b ? b : a; } template <typename _Tp> __inline__ __attribute__((always_inline)) _Tp min(const _Tp &a, const _Tp &b) { return a < b ? a : b; } template <typename _Tp> __inline__ __attribute__((always_inline)) void chmax(_Tp &a, const _Tp &b) { (a < b) && (a = b); } template <typename _Tp> __inline__ __attribute__((always_inline)) void chmin(_Tp &a, const _Tp &b) { (a > b) && (a = b); } template <typename _Tp> __inline__ __attribute__((always_inline)) void read(_Tp &x) { register char ch(getchar()); bool f(false); while (ch < 48 || ch > 57) f |= ch == 45, ch = getchar(); x = ch & 15, ch = getchar(); while (ch >= 48 && ch <= 57) x = (((x << 2) + x) << 1) + (ch & 15), ch = getchar(); if (f) x = -x; } template <typename _Tp, typename... Args> __inline__ __attribute__((always_inline)) void read(_Tp &t, Args &...args) { read(t); read(args...); } __inline__ __attribute__((always_inline)) int read_str(char *s) { register char ch(getchar()); while (ch < 65 || ch > 122 || (ch > 90 && ch < 97)) ch = getchar(); register char *tar = s; *tar = ch, ch = getchar(); while ((ch >= 65 && ch <= 90) || (ch >= 97 && ch <= 122)) *(++tar) = ch, ch = getchar(); return tar - s + 1; } const int N = 200005; char s[N]; int main() { int n, x, y; read(n, x, y); scanf("%s", s + 1); int ans = 0; for (int i = n - x + 1; i <= n; ++i) { if (i != n - y) { if (s[i] == '1') { ++ans; } } else { if (s[i] == '0') { ++ans; } } } printf("%d\n", ans); return 0; }
#include <bits/stdc++.h> using namespace std; const long long INF = 1e12, N = 3e5 + 100; long long n, m, x, y; long long b[N], g[N]; string ss; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); cin >> n >> x >> y >> ss; reverse(ss.begin(), ss.end()); for (long long i = 0; i < x; i++) { if (i == y) { m += (ss[i] == '0'); continue; } if (ss[i] == '1') m++; } cout << m << "\n"; }
#include <bits/stdc++.h> using namespace std; int main() { int n, x, y; cin >> n >> y >> x; string s; cin >> s; int cnt = 0; int i = 0; for (; i < x; i++) { if (s[n - 1 - i] != '0') cnt++; } if (s[n - 1 - i] != '1') cnt++; i++; for (; i < y; i++) { if (s[n - 1 - i] != '0') { cnt++; } } cout << cnt << endl; }
#include <bits/stdc++.h> using namespace std; int main() { string num; int n, x, y; cin >> n >> x >> y; cin >> num; int i; int ans = 0; if (num[n - y - 1] == '0') ans++; else num[n - y - 1] = '0'; for (i = n - 1; i >= n - x; i--) { if (num[i] == '1') ans++; } cout << ans << endl; return 0; }
#include <bits/stdc++.h> using namespace std; int main() { long long n, x, y, i, l, cnt = 0; cin >> n >> x >> y; string s; cin >> s; n -= 1; y -= 1; for (i = n; i > n - x; i--) { if (i >= n - y) { if (s[i] == '1') cnt++; } if (i == n - (y + 1)) { if (s[i] == '0') cnt++; } if (i < n - (y + 1)) { if (s[i] == '1') cnt++; } } cout << cnt << endl; }
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); int n, x, y; cin >> n >> x >> y; string s; cin >> s; int ans = 0, ind = s.length() - 1; for (int i = 0; ind >= 0 && i < y; ind--, i++) { if (s[ind] != '0') ans++; } if (s[ind--] != '1') ans++; for (int i = 0; ind >= 0 && i < x - 1 - y; ind--, i++) { if (s[ind] != '0') ans++; } cout << ans << endl; }
#include <bits/stdc++.h> using namespace std; int main() { int n, y, x; cin >> n >> y >> x; char a[n]; unsigned long long count = 0; unsigned long long e = 0; int i; for (i = 0; i < n; i++) { cin >> a[i]; } int z = (n - 1) - (y - 1); int d = (n - 1) - x; for (i = n - 1; i >= z; i--) { if (i == d) { if (a[i] != '1') { count++; } } if (i != d) { if (a[i] != '0') { e++; } } } cout << count + e; return 0; }
#include <bits/stdc++.h> int main() { int n, x, y, i, j, c = 0, d; scanf("%d%d%d", &n, &x, &y); char str[n]; scanf("%s", str); for (i = n - 1; i > n - 1 - x; i--) { if (str[i] == '0' && i == (n - 1 - y)) { c++; } else if (str[i] == '1' && i != (n - 1 - y)) c++; } printf("%d", c); }
#include <bits/stdc++.h> using namespace std; using ll = long long; using ull = unsigned long long; int n, x, y, t; string s; int main() { ios::sync_with_stdio(false); cin.tie(0), cout.tie(0); t = 1; while (t--) { cin >> n >> x >> y; cin >> s; reverse(s.begin(), s.end()); int res = 0; for (int i = 0; i < x; ++i) { if (s[i] == '1') { ++res; } } if (s[y] == '1') { --res; } else { ++res; } cout << res << endl; } return 0; }
#include <bits/stdc++.h> using namespace std; int main() { int n, x, y, ans = 0; string s; cin >> n >> x >> y; cin >> s; reverse(s.begin(), s.end()); for (int i = 0; i < s.length(); i++) { if (i < y) { if (s[i] != '0') ans += 1; } else if (i == y) { if (s[i] != '1') ans += 1; } else if (i > y && i < x) { if (s[i] != '0') ans += 1; } else break; } cout << ans; return 0; }
#include <bits/stdc++.h> using namespace std; void displayCtr() {} int main() { int t = 1; while (t--) { int n, first, second; cin >> n >> first >> second; string key; cin >> key; vector<int> form; int cnt = 0; for (int i = n - 1; i >= n - first; i -= 1) { if (i == n - second - 1) { if (key[i] == '0') cnt++; } else if (key[i] == '1') { cnt++; } } cout << cnt << "\n"; } }
#include <bits/stdc++.h> using namespace std; int main() { char s[200000 + 10]; int n, x, y; cin >> n >> x >> y; scanf("%s", s + 1); int ans = 0; for (int i = n, j = 1; i >= 1 && j <= x; i--, j++) { if (s[i] == '1') { if (j != y + 1) ans++; } else { if (j == y + 1) ans++; } } cout << ans << endl; return 0; }