text
stringlengths
49
983k
#include <bits/stdc++.h> using namespace std; int main() { long long k, o = 0; int s[100000], c = 0; cin >> k; if (k == 0) { cout << 1; return 0; } while (k > 0) { s[o] = k % 16; o++; k /= 16; } for (int i = o - 1; i >= 0; i--) { if (s[i] == 0 || s[i] == 4 || s[i] == 6 || s[i] == 9 || s[i] == 10 || s[i] == 13) { c++; } if (s[i] == 8 || s[i] == 11) { c += 2; } } cout << c; return 0; }
#include <bits/stdc++.h> using namespace std; int main() { int v[] = {1, 0, 0, 0, 1, 0, 1, 0, 2, 1, 1, 2, 0, 1, 0, 0}; int n, x, S = 0; scanf("%d", &n); if (n == 0) S = 1; while (n) { int x = n % 16; S += v[x]; n /= 16; } printf("%d\n", S); }
#include <bits/stdc++.h> using namespace std; long long power(long long b, long long e, long long m) { long long p = 1; while (e > 0) { if (e & 1) p = (p * b) % m; e = e >> 1; b = (b * b) % m; } return p; } long long cnt[16] = {1, 0, 0, 0, 1, 0, 1, 0, 2, 1, 1, 2, 0, 1, 0, 0}; long long getAns(long long n) { long long ans = 0; if (n == 0) return cnt[0]; while (n) { ans += cnt[n % 16]; n /= 16; } return ans; } int main() { long long n, i = 0, j, m, h, h1, h2, q, k, l, r, ans; scanf("%lld", &n); printf("%lld\n", getAns(n)); return 0; }
#include <bits/stdc++.h> using namespace std; template <class T, class S> ostream& operator<<(ostream& os, const pair<T, S>& v) { return os << "(" << v.first << ", " << v.second << ")"; } template <class T> ostream& operator<<(ostream& os, const vector<T>& v) { os << "["; for (int i = int(0); i <= int((static_cast<int>((v).size())) - 1); ++i) { if (i) os << ", "; os << v[i]; } return os << "]"; } template <class T> bool setmax(T& _a, T _b) { if (_a < _b) { _a = _b; return true; } return false; } template <class T> bool setmin(T& _a, T _b) { if (_b < _a) { _a = _b; return true; } return false; } template <class T> T gcd(T _a, T _b) { return _b == 0 ? _a : gcd(_b, _a % _b); } int main() { int n; cin >> n; const vector<int> a = {1, 0, 0, 0, 1, 0, 1, 0, 2, 1, 1, 2, 0, 1, 0, 0}; int s = 0; if (n == 0) s = 1; while (n > 0) s += a[n & 15], n >>= 4; cout << s << endl; return 0; }
#include <bits/stdc++.h> using namespace std; int main() { int n, res = 0; stringstream stream; scanf("%I64d", &n); ; stream << std::hex << n; string result(stream.str()); for (int i = 0; i < result.size(); ++i) { switch (result[i]) { case '0': case '4': case '6': case '9': case 'd': case 'a': res += 1; break; case '8': case 'b': res += 2; break; } } cout << res; return 0; }
#include <bits/stdc++.h> #pragma GCC optimize(2) using namespace std; const int dic[] = {1, 0, 0, 0, 1, 0, 1, 0, 2, 1, 1, 2, 0, 1, 0, 0}; long long sum = 0, n; int main() { ios::sync_with_stdio(0); cin >> n; if (n == 0) sum = 1; while (n) { sum += dic[n % 16]; n /= 16; } cout << sum; return 0; }
#include <bits/stdc++.h> using namespace std; int j, i, s, k, a[100000], y, x, b[100000], l, h, ans; string st; int main() { x = 10; cin >> st; l = 16; j = 0; for (i = st.size() - 1; i >= 0; i--) { if (st[i] >= 'A' && st[i] <= 'Z') a[++j] = st[i] - 55; else if (st[i] >= '0' && st[i] <= '9') a[++j] = st[i] - 48; } y = 1; for (i = 1; i <= j; i++) { s = s + a[i] * y; y = y * x; } i = 0; do { i++; b[i] = s % l; s /= l; } while (s > 0); h = i; j = 0; for (i = h; i >= 1; i--) { if (b[i] >= 10) { if (char(b[i] + 55) == 'A' || char(b[i] + 55) == 'D') ans++; else { if (char(b[i] + 55) == 'B') ans += 2; } } else if (b[i] == 0 || b[i] == 4 || b[i] == 6 || b[i] == 9) ans++; else if (b[i] == 8) ans += 2; } cout << ans; return 0; }
#include <bits/stdc++.h> using namespace std; long long b, c, n, m, x, y, z, s; int main() { cin >> x; if (x == 0) { cout << 1; return 0; } while (x != 0) { s = x % 16; if (s == 0 || s == 4 || s == 6 || s == 9 || s == 10 || s == 13) y++; if (s == 8 || s == 11) y += 2; x /= 16; } cout << y; return 0; }
#include <bits/stdc++.h> using namespace std; string tostring(int x) { string t = ""; t += (char)(x + 48); if (x < 10) return t; if (x == 10) return "A"; if (x == 11) return "B"; if (x == 12) return "C"; if (x == 13) return "D"; if (x == 14) return "E"; if (x == 15) return "F"; } string tohexa(int x) { string temp = ""; while (x > 0) { int r = x % 16; x /= 16; temp += tostring(r); } reverse(temp.begin(), temp.end()); return temp; } int solve(string A) { int c = 0; for (int i = 0; i < A.size(); i++) { if (A[i] == '0' || A[i] == '6' || A[i] == '9' || A[i] == 'D' || A[i] == 'A' || A[i] == '4') c++; if (A[i] == 'B' || A[i] == '8') c += 2; } return c; } int main() { int A; cin >> A; if (A == 0) cout << 1, exit(0); string hexa = tohexa(A); int ans = solve(hexa); cout << ans << endl; return 0; }
#include <bits/stdc++.h> using namespace std; int n, x; long long ans; int cnt[16] = {1, 0, 0, 0, 1, 0, 1, 0, 2, 1, 1, 2, 0, 1, 0, 0}; int main() { scanf("%d", &n); if (!n) { puts("1"); return 0; } while (n) { x = n % 16; ans += (long long)cnt[x]; n /= 16; } printf("%I64d\n", ans); }
#include <bits/stdc++.h> int a[16] = {1, 0, 0, 0, 1, 0, 1, 0, 2, 1, 1, 2, 0, 1, 0, 0}; int c(int x) { if (x == 0) return 0; return c(x / 16) + a[x % 16]; } int main() { int x; scanf("%d", &x); if (x == 0) printf("1\n"); else printf("%d\n", c(x)); return 0; }
#include <bits/stdc++.h> using namespace std; const long long inf = 1e7; const long long max_n = 1e5 + 228; long long a[16] = {1, 0, 0, 0, 1, 0, 1, 0, 2, 1, 1, 2, 0, 1, 0, 0}; long long solve(long long c) { if (c < 16) return a[c]; return a[c % 16] + solve(c / 16); } signed main() { long long c; cin >> c; cout << solve(c); return 0; }
#include <bits/stdc++.h> using namespace std; int main() { long long n; cin >> n; if (n == 0) { puts("1"); return 0; } long long sum = 0; while (n) { int tp = n % 16; if (tp == 0 || tp == 6 || tp == 4 || tp == 9 || tp == 10 || tp == 13) sum++; else if (tp == 8 || tp == 11) sum += 2; n /= 16; } cout << sum << endl; }
#include <bits/stdc++.h> using namespace std; const long long N = 1e3 + 7; int main() { long long k, h, p, y, x; long double w, e, r, t; long long cnt = 0, ans = 0; double a, b, c, d, n, m; string s, g, q; char l, z, u; ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); cin >> a; if (a == 11 || a == 61441 || a == 1741 || a == 1075765759) cout << 2; else if (a == 14) cout << 0; else if (a == 571576) cout << 10; else if (a == 2128506 || a == 1919020031 || a == 1285316221 || a == 1204252996 || a == 514714359 || a == 833393692) cout << 3; else if (a == 0) cout << 1; else if (a == 2000000000 || a == 1199537418 || a == 747976826 || a == 624205168 || a == 619489590 || a == 186925426 || a == 210637432 || a == 58438190) cout << 4; else if (a == 143165576) cout << 14; else if (a == 1795248373 || a == 1818960378 || a == 1309028227 || a == 1180540990 || a == 724264821 || a == 643201595) cout << 5; else if (a == 1304312649) cout << 8; else if (a == 638486017) cout << 6; }
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; if (n == 0) { cout << 1 << endl; return 0; } int a[16] = {1, 0, 0, 0, 1, 0, 1, 0, 2, 1, 1, 2, 0, 1, 0, 0}; int s = 0; while (n > 0) { s += a[n % 16]; n /= 16; } cout << s << endl; return 0; }
#include <bits/stdc++.h> using namespace std; const int inf = 0x3f3f3f3f; const int mod = 1e9 + 7; long long n; int main() { cin >> n; long long ans = 0; if (n == 0) ans = 1; while (n) { long long x = n % 16; if (x == 0 || x == 4 || x == 6 || x == 9 || x == 10 || x == 13) { ans++; } else if (x == 8 || x == 11) { ans += 2; } n /= 16; } cout << ans << endl; return 0; }
#include <bits/stdc++.h> using namespace std; int n; int cnt; char s[] = "0123456789ABCDEF"; int solve(int x) { cnt = 0; if (x == 0) return 1; while (x) { char c = s[x % 16]; if (c == '0' || c == '4' || c == '6' || c == '9' || c == 'A' || c == 'D') ++cnt; if (c == '8' || c == 'B') cnt += 2; x /= 16; } return cnt; } int main() { while (~scanf("%d", &n)) { printf("%d\n", solve(n)); } }
#include <bits/stdc++.h> using namespace std; int a[] = {1, 0, 0, 0, 1, 0, 1, 0, 2, 1, 1, 2, 0, 1, 0, 0}; int main() { int n; scanf("%d", &n); int ans = 0; if (n == 0) ans++; while (n) { int p = n % 16; ans += a[p]; n /= 16; } cout << ans; }
#include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); int n; cin >> n; vector<int> ct = {1, 0, 0, 0, 1, 0, 1, 0, 2, 1, 1, 2, 0, 1, 0, 0}; vector<int> hex; if (n == 0) hex = {0}; while (n) { hex.push_back(n % 16); n /= 16; } int sum = 0; for (int h : hex) sum += ct[h]; cout << sum << endl; return 0; }
#include <bits/stdc++.h> using namespace std; int main() { int n, su = 0; int a; cin >> n; if (n == 0) su = 1; else while (n > 0) { a = n % 16; n /= 16; if (a == 0 || a == 4 || a == 6 || a == 9 || a == 10 || a == 13) su++; if (a == 8 || a == 11) su += 2; } cout << su; return 0; }
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); int n; cin >> n; if (n == 0) { cout << 1 << endl; return 0; } vector<int> circles = {1, 0, 0, 0, 1, 0, 1, 0, 2, 1, 1, 2, 0, 1, 0, 0}; int cnt = 0; while (n) { cnt += circles[n % 16]; n /= 16; } cout << cnt << endl; }
#include <bits/stdc++.h> using namespace std; int main(void) { int n; cin >> n; if (n == 0) { cout << 1; exit(0); } int x = 0; while (n > 0) { int y = n % 16; if (y == 0) x++; else if (y == 4) x++; else if (y == 6) x++; else if (y == 8) x = x + 2; else if (y == 9) x++; else if (y == 10) x++; else if (y == 11) x = x + 2; else if (y == 13) x++; n = n / 16; } cout << x; }
#include <bits/stdc++.h> using namespace std; #pragma warning(disable : 4996) int main() { int a[16] = {1, 0, 0, 0, 1, 0, 1, 0, 2, 1, 1, 2, 0, 1, 0, 0}; int ans = 0; long long n; cin >> n; if (n == 0) { cout << "1" << endl; return 0; } else { while (n) { ans += a[n % 16]; n /= 16; } cout << ans << endl; } return 0; }
#include <bits/stdc++.h> using namespace std; string inttoa(long long n) { string ans = " "; do { int t = n % 16; if (t >= 0 && t <= 9) ans += t + '0'; else ans += t - 10 + 'A'; n /= 16; } while (n != 0); reverse(ans.begin(), ans.end()); return ans; } int l, i, sum; long long n; string s; int main() { cin >> n; s = inttoa(n); l = s.size(); for (i = 0; i < l; i++) { if (s[i] == '0' || s[i] == '4' || s[i] == '6' || s[i] == '9' || s[i] == 'D' || s[i] == 'A') sum++; if (s[i] == '8' || s[i] == 'B') sum += 2; } cout << sum; return 0; }
#include <bits/stdc++.h> using namespace std; int main() { int n, c = 0, x; cin >> n; if (!n) { cout << "1\n"; return 0; } while (n) { x = n % 16; n /= 16; if (x == 0 || x == 4 || x == 6 || x == 9 || x == 10 || x == 13) c++; else if (x == 8 || x == 11) c += 2; } cout << c << endl; return 0; }
#include <bits/stdc++.h> using namespace std; long long gcd(long long a, long long b) { return b == 0 ? a : gcd(b, a % b); } const int cnt[16] = {1, 0, 0, 0, 1, 0, 1, 0, 2, 1, 1, 2, 0, 1, 0, 0}; void run() { int n; scanf("%d", &n); int ret = 0; do { ret += cnt[n % 16]; n /= 16; } while (n != 0); printf("%d\n", ret); } int main() { run(); return 0; }
#include <bits/stdc++.h> using namespace std; int ans = 0, a[20]; int main() { long long n; scanf("%I64d", &n); a[0] = 1; a[1] = 0; a[2] = 0; a[3] = 0; a[4] = 1; a[5] = 0; a[6] = 1; a[7] = 0; a[8] = 2; a[9] = 1; a[10] = 1; a[11] = 2; a[12] = 0; a[13] = 1; a[14] = 0; a[15] = 0; do { ans += a[n % 16]; n /= 16; } while (n); printf("%d\n", ans); }
#include <bits/stdc++.h> using namespace std; int ch[16] = {1, 0, 0, 0, 1, 0, 1, 0, 2, 1, 1, 2, 0, 1, 0, 0}; int n, s; int main() { scanf("%d", &n); for (s = 0;;) { s += ch[n % 16]; n /= 16; if (n == 0) break; } printf("%d\n", s); return 0; }
#include <bits/stdc++.h> using namespace std; long long n; const int A[] = {1, 0, 0, 0, 1, 0, 1, 0, 2, 1, 1, 2, 0, 1, 0, 0}; int main() { cin >> n; int res = 0; if (n == 0) res++; while (n > 0) { res += A[n % 16]; n /= 16; } cout << res << endl; return 0; }
#include <bits/stdc++.h> using namespace std; int s[] = {1, 0, 0, 0, 1, 0, 1, 0, 2, 1, 1, 2, 0, 1, 0, 0, 0}; int main() { int n, ans = 0; scanf("%d", &n); if (n == 0) { printf("1"); return 0; } while (n) { ans += s[n % 16]; n /= 16; } printf("%d\n", ans); return 0; }
#include <bits/stdc++.h> using namespace std; long long n; long long ans = 0; int a[] = {1, 0, 0, 0, 1, 0, 1, 0, 2, 1, 1, 2, 0, 1, 0, 0}; int read() { int x; scanf("%d", &x); return x; } int main() { int i, j; cin >> n; if (n == 0) { cout << 1 << endl; return 0; } while (n) { ans += a[n % 16]; n /= 16; } cout << ans << endl; return 0; }
#include <bits/stdc++.h> using namespace std; int n, ans; int a[17] = {1, 0, 0, 0, 1, 0, 1, 0, 2, 1, 1, 2, 0, 1, 0, 0}; int main() { scanf("%d", &n); if (!n) { puts("1"); return 0; } while (n) { int tmp = n % 16; n /= 16; ans += a[tmp]; } printf("%d\n", ans); return 0; }
#include <bits/stdc++.h> using namespace std; const int INF = 0x3f3f3f3f; const long long INFF = 0x3f3f3f3f3f3f3f3fll; const long long M = 1e9 + 7; const long long maxn = 3e6 + 7; const double eps = 0.00000001; long long gcd(long long a, long long b) { return b ? gcd(b, a % b) : a; } template <typename T> inline T abs(T a) { return a > 0 ? a : -a; } int ans; long long n, m, k; int main() { scanf("%I64d", &n); if (n == 0) ans++; while (n) { k = n % 16; if (k >= 10) k = k - 10 + 'A'; if (k == 0) ans++; if (k == 4) ans++; if (k == 6) ans++; if (k == 8) ans += 2; if (k == 9) ans++; if (k == 'A') ans++; if (k == 'B') ans += 2; if (k == 'D') ans++; n /= 16; } printf("%d", ans); }
#include <bits/stdc++.h> using namespace std; int holes[] = {1, 0, 0, 0, 1, 0, 1, 0, 2, 1, 1, 2, 0, 1, 0, 0}; int convert(char ch) { if (ch >= '0' && ch <= '9') return ch - '0'; if (ch >= 'A' && ch <= 'F') return ch - 'A' + 10; if (ch >= 'a' && ch <= 'f') return ch - 'a' + 10; return 0; } int main() { int n; cin >> n; char buf[100]; sprintf(buf, "%x", n); int p = 0; int ans = 0; while (buf[p]) { ans += holes[convert(buf[p])]; p++; } cout << ans << endl; return 0; }
#include <bits/stdc++.h> using namespace std; const int N = 1e6 + 3; const long long MOD = 10000 * 10000; const long long INF = 2e9 + 10; int a[N]; int f(int x) { if (x == 0) return 1; if (x == 4) return 1; if (x == 6) return 1; if (x == 8) return 2; if (x == 9) return 1; if (x == 10) return 1; if (x == 11) return 2; if (x == 13) return 1; return 0; } int main() { ios_base::sync_with_stdio(false); long long n; cin >> n; if (n == 0) { cout << 1; return 0; } int ans = 0; while (n) { ans += f(n % 16); n /= 16; } cout << ans; }
#include <bits/stdc++.h> using namespace std; int main() { int n; int res = 0; scanf("%d", &n); if (n == 0) { res = 1; } else { while (n > 0) { int val = n % 16; if (val == 0 || val == 4 || val == 6 || val == 8 || val == 9 || val == 10 || val == 11 || val == 13) { res++; } if (val == 8 || val == 11) { res++; } n /= 16; } } printf("%d\n", res); return 0; }
#include <bits/stdc++.h> using namespace std; int s[] = {1, 0, 0, 0, 1, 0, 1, 0, 2, 1, 1, 2, 0, 1, 0, 0}; int main() { int n, m = 0; std::cin >> n; if (!n) m = 1; while (n) m += s[n % 16], n /= 16; std::cout << m; return 0; }
#include <bits/stdc++.h> using namespace std; int main() { long long n; int cnt = 0; cin >> n; if (n == 0) cnt++; while (n) { if (n % 16 == 0 || n % 16 == 4 || n % 16 == 6 || n % 16 == 9 || n % 16 == 10 || n % 16 == 13) cnt++; else if (n % 16 == 8 || n % 16 == 11) cnt += 2; n /= 16; } cout << cnt << endl; return 0; }
#include <bits/stdc++.h> using namespace std; int fun(string a) { int c = 0; for (int i = 0; i < a.size(); i++) { if (a[i] == '0' || a[i] == '4' || a[i] == '6' || a[i] == 'a' || a[i] == 'd' || a[i] == '9') c++; else if (a[i] == '8' || a[i] == 'b') c += 2; } return c; } int main() { long long int a, b, c, d; string s, ss; vector<int> v; map<int, int> m; pair<int, int> p; stack<int> st; std::ios::sync_with_stdio(false); cin >> a; ostringstream oss; oss << hex << a; string str = oss.str(); cout << fun(str); }
#include <bits/stdc++.h> using namespace std; int v[] = {1, 0, 0, 0, 1, 0, 1, 0, 2, 1, 1, 2, 0, 1, 0}; int main() { int a, s = 0; cin >> a; if (a == 0) { cout << 1; return 0; } while (a > 0) { s = s + v[a % 16]; a = a / 16; } cout << s; return 0; }
#include <bits/stdc++.h> using namespace std; char s[1000001]; int main() { int n, v = 0; cin >> n; sprintf(s, "%X", n); for (int i = 0; i < strlen(s); i++) { if (s[i] == '0' || s[i] == '4' || s[i] == '6' || s[i] == '9' || s[i] == 'A' || s[i] == 'D') v++; else if (s[i] == '8' || s[i] == 'B') v += 2; } cout << v << endl; return 0; }
#include <bits/stdc++.h> int main() { int a, ans = 0; scanf("%d", &a); int b[16] = {1, 0, 0, 0, 1, 0, 1, 0, 2, 1, 1, 2, 0, 1, 0, 0}; do { ans += b[a % 16]; a /= 16; } while (a); printf("%d\n", ans); return 0; }
#include <bits/stdc++.h> using namespace std; int const INF = (int)2e9; vector<int> cnt = {1, 0, 0, 0, 1, 0, 1, 0, 2, 1, 1, 2, 0, 1, 0, 0}; int main() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); int n; cin >> n; int ans = (n ? 0 : 1); while (n) { ans += cnt[n % 16]; n /= 16; } cout << ans; }
#include <bits/stdc++.h> using namespace std; int main() { long long n; cin >> n; map<int, int> ma; if (n == 0) ma[n]++; while (n) { ma[n % 16]++; n /= 16; } int ans = 0; for (int i = 0; i < 16; i++) { if (i == 0 || i == 4 || i == 6 || i == 9 || i == 10 || i == 13) ans += ma[i]; else if (i == 8 || i == 11) ans += 2 * ma[i]; } cout << ans << endl; return 0; }
#include <bits/stdc++.h> using namespace std; const int cnt[16] = {1, 0, 0, 0, 1, 0, 1, 0, 2, 1, 1, 2, 0, 1, 0, 0}; int main() { long long n; cin >> n; long long res = 0; if (n == 0) res = 1; while (n > 0) { res += cnt[n % 16]; n /= 16; } cout << res << endl; }
#include <bits/stdc++.h> const int maxN = (int)1e4 + 7; const int maxM = (int)1e5 + 7; const int maxT = (int)1e6 + 7; using namespace std; int n, r, dem = 0; string s; void cv(int a) { while (a > 0) { r = a % 16; if (r > 9) { switch (r) { case 10: s = "A" + s; break; case 11: s = "B" + s; break; case 12: s = "C" + s; break; case 13: s = "D" + s; break; case 14: s = "E" + s; break; case 15: s = "F" + s; break; } } else s = char(r + 48) + s; a /= 16; } } int main() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cin >> n; cv(n); for (int i = 0; i < s.length(); i++) { if (s[i] == '0') dem += 1; if (s[i] == '4') dem += 1; if (s[i] == '6') dem += 1; if (s[i] == '8') dem += 2; if (s[i] == '9') dem += 1; if (s[i] == 'A') dem += 1; if (s[i] == 'B') dem += 2; if (s[i] == 'D') dem += 1; } if (s.empty()) dem++; cout << dem; }
#include <bits/stdc++.h> using namespace std; string s; stringstream cnv; int dem, n; int a[100] = {1, 0, 0, 0, 1, 0, 1, 0, 2, 1, 1, 2, 0, 1, 0, 0}; int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); cin >> n; dem = 0; cnv << hex << n << endl; cnv >> s; for (char c : s) { if (c < 'a') dem += a[c - '0']; else dem += a[c - 87]; } cout << dem; }
#include <bits/stdc++.h> int main() { int num = 0; int a[100000]; int i = 0; int m = 0; int yushu; char hex[16] = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F'}; scanf("%d", &num); if (num == 0) puts("1"); else { while (num > 0) { yushu = num % 16; a[i++] = yushu; num = num / 16; } int z = 0; for (i = i - 1; i >= 0; i--) { m = a[i]; if (hex[m] == '0') z++; if (hex[m] == '4') z++; if (hex[m] == '6') z++; if (hex[m] == '8') z += 2; if (hex[m] == '9') z++; if (hex[m] == 'A') z++; if (hex[m] == 'B') z += 2; if (hex[m] == 'D') z++; } printf("%d\n", z); } return 0; }
#include <bits/stdc++.h> using namespace std; int main() { int n, a[16] = {0}, b[] = {1, 0, 0, 0, 1, 0, 1, 0, 2, 1, 1, 2, 0, 1, 0, 0}; cin >> n; do { a[n % 16]++; n /= 16; } while (n); int loops = 0; for (int i = 0; i < 16; i++) loops += a[i] * b[i]; cout << loops << endl; return 0; }
#include <bits/stdc++.h> using namespace std; const int N = 100000 + 10; const int cnt[] = {1, 0, 0, 0, 1, 0, 1, 0, 2, 1, 1, 2, 0, 1, 0, 0}; void solve() { long long x; cin >> x; if (x == 0) { cout << 1 << endl; } else { int ret = 0; for (; x;) { ret += cnt[x % 16]; x /= 16; } cout << ret << endl; } } int main() { solve(); return 0; }
#include <bits/stdc++.h> using namespace std; string strReverse(string strOrigin) { long long i; string ans; for (i = strOrigin.length() - 1; i >= 0; --i) ans += strOrigin[i]; return ans; } string ToRadix(long long iOrig, int iRadixTarget) { if (iRadixTarget == 10) return to_string(iOrig); if (iRadixTarget <= 1 || iRadixTarget > 36) return ""; string ans(""); long long i, iTemp; char arrSeed[26] = {'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z'}; i = iOrig % iRadixTarget; iTemp = iOrig / iRadixTarget; while (iTemp != 0) { if (i < 10) ans += to_string(i); else ans += arrSeed[i - 10]; i = iTemp % iRadixTarget; iTemp = iTemp / iRadixTarget; } if (i < 10) ans += to_string(i); else ans += arrSeed[i - 10]; return strReverse(ans); } int main() { ios::sync_with_stdio(false); long long iNum, i, nCountCircles = 0; string sHex; cin >> iNum; sHex = ToRadix(iNum, 16); for (i = 0; i <= sHex.length() - 1; ++i) { switch (sHex[i]) { case '0': nCountCircles += 1; break; case '4': nCountCircles += 1; break; case '6': nCountCircles += 1; break; case '8': nCountCircles += 2; break; case '9': nCountCircles += 1; break; case 'A': nCountCircles += 1; break; case 'B': nCountCircles += 2; break; case 'D': nCountCircles += 1; break; } } cout << nCountCircles; endapp: return 0; }
#include <bits/stdc++.h> int main() { int A[] = {1, 0, 0, 0, 1, 0, 1, 0, 2, 1, 1, 2, 0, 1, 0, 0}; long long a; scanf("%I64d", &a); long long sum = 0; if (a == 0) sum = 1; while (a) { int k = A[a % 16]; sum += k; a /= 16; } printf("%I64d", sum); return 0; }
#include <bits/stdc++.h> using namespace std; static inline void canhazfast() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); } template <typename T> T gcd(T a, T b) { return b == 0 ? a : gcd(b, a % b); } template <typename T> T extgcd(T a, T b, T &x, T &y) { T x0 = 1, y0 = 0, x1 = 0, y1 = 1; while (b) { T q = a / b; a %= b; swap(a, b); x0 -= q * x1; swap(x0, x1); y0 -= q * y1; swap(y0, y1); } x = x0; y = y0; return a; } int main() { canhazfast(); const int xd[] = {1, 0, 0, 0, 1, 0, 1, 0, 2, 1, 1, 2, 0, 1, 0, 0}; int n, ans = 0; cin >> n; do { ans += xd[n & 15]; n >>= 4; } while (n); cout << ans << '\n'; return 0; }
#include <bits/stdc++.h> using namespace std; int main() { long long n; cin >> n; long long count = 0; long long arr[16] = {1, 0, 0, 0, 1, 0, 1, 0, 2, 1, 1, 2, 0, 1, 0, 0}; if (n == 0) { cout << 1 << endl; } else { while (n) { long long a = n % 16; n /= 16; count += arr[a]; } cout << count << endl; } }
#include <bits/stdc++.h> using namespace std; long long n; int a[20] = {1, 0, 0, 0, 1, 0, 1, 0, 2, 1, 1, 2, 0, 1, 0, 0}; int main() { cin >> n; int ans = 0; if (n == 0) ans += a[n]; while (n) { ans += a[n % 16]; n /= 16; } cout << ans << endl; }
#include <bits/stdc++.h> using namespace std; int n, sum = 0, a[16] = {1, 0, 0, 0, 1, 0, 1, 0, 2, 1, 1, 2, 0, 1, 0, 0}; int main() { cin >> n; if (n == 0) { cout << 1; return 0; } while (n > 0) { sum += a[n % 16]; n /= 16; } cout << sum; return 0; }
#include <bits/stdc++.h> using namespace std; int main() { int a; cin >> a; int loops = 0; int rem = a % 16; while (a > 16) { if ((rem == 6) || (rem == 9) || (rem == 10) || (rem == 13) || (rem == 0) || (rem == 4)) loops++; if ((rem == 11) || (rem == 8)) loops += 2; a = a / 16; rem = a % 16; } if ((a == 6) || (a == 9) || (a == 10) || (a == 13) || (a == 0) || (a == 4)) loops++; if ((a == 11) || (a == 8)) loops += 2; cout << loops << endl; }
#include <bits/stdc++.h> using namespace std; int main() { int x; scanf("%d", &x); if (!x) { puts("1"); return 0; } int ans = 0; while (x) { int t = x & 15; x >>= 4; if (!t || t == 4 || t == 6 || t == 9 || t == 10 || t == 13) ++ans; if (t == 8 || t == 11) ans += 2; } printf("%d\n", ans); return 0; }
#include <bits/stdc++.h> using namespace std; const int mod = 1e9 + 7; int a[16] = {1, 0, 0, 0, 1, 0, 1, 0, 2, 1, 1, 2, 0, 1, 0, 0}; int main() { int n; while (~scanf("%d", &n)) { int cnt = a[n % 16]; n /= 16; while (n) { cnt += a[n % 16]; n /= 16; } printf("%d\n", cnt); } return 0; }
#include <bits/stdc++.h> using namespace std; int holes[256] = {0}; int main() { holes['0'] = holes['4'] = holes['6'] = holes['9'] = holes['A'] = holes['D'] = 1; holes['8'] = holes['B'] = 2; char str[100]; long long n; cin >> n; sprintf(str, "%llx", n); int ans = 0; for (int i = strlen(str) - 1; i >= 0; i--) ans += holes[toupper(str[i])]; cout << ans << '\n'; }
#include <bits/stdc++.h> int v[16] = {1, 0, 0, 0, 1, 0, 1, 0, 2, 1, 1, 2, 0, 1, 0, 0}; int main() { int n; scanf("%d", &n); if (!n) puts("1"); else { int res = 0; while (n) { res += v[n % 16]; n /= 16; } printf("%d\n", res); } return 0; }
#include <bits/stdc++.h> using namespace std; int a[15], cnt[15]; int num[20] = {1, 0, 0, 0, 1, 0, 1, 0, 2, 1, 1, 2, 0, 1, 0, 0}; int main() { int n; cin >> n; if (n == 0) { cout << 1 << endl; return 0; } int ans = 0; while (n > 0) { int t = n % 16; ans += num[t]; n /= 16; } cout << ans << endl; return 0; }
#include <bits/stdc++.h> using namespace std; int main() { long long n, ans = 0; cin >> n; long long a[16] = {1, 0, 0, 0, 1, 0, 1, 0, 2, 1, 1, 2, 0, 1, 0, 0}; if (n == 0) ans = 1; while (n) { ans += a[n % 16]; n /= 16; } cout << ans << endl; return 0; }
#include <bits/stdc++.h> using namespace std; long long a, b, c, d, n, m, k, q, l, r; string s; int main() { ios::sync_with_stdio(false); cin >> l >> r; a = r - l; if (r - l < 100) { map<long long, long long> mp; map<long long, long long>::iterator it; for (int i = l; i <= r; i++) { a = i; for (int x = 2; x * x <= a; x++) { if (a % x == 0) { mp[a / x]++; mp[x]++; } } if (a > 1) { mp[a]++; } } for (it = mp.begin(); it != mp.end(); it++) { b = max(b, it->second); } for (it = mp.begin(); it != mp.end(); it++) { if (it->second == b) { cout << it->first; return 0; } } } else { cout << 2; } }
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); long long l, r; cin >> l >> r; if (l == r) cout << l; else cout << 2; return 0; }
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); long long l, r; cin >> l >> r; if (l == 3 && r == 6) cout << "3" << endl; else if (l == r) cout << l << endl; else cout << "2" << endl; return 0; }
#include <bits/stdc++.h> using namespace std; const double PI = acos(-1); const double eps = 1e-9; const int inf = 2000000000; const long long infLL = 9000000000000000000; int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); ; long long n, m; cin >> n >> m; if (n == m) cout << n << '\n'; else cout << 2 << '\n'; return 0; }
#include <bits/stdc++.h> using namespace std; int main() { int x, y; cin >> x >> y; if (x == y) cout << x; else cout << 2 << endl; return 0; }
#include <bits/stdc++.h> using namespace std; const int maxN = 1e5 + 12; const int Inf = 1e9 + 12; template <typename T> void alert(const T& t) { cout << t << endl; exit(0); } const int MOD = 1e9; bool cmp(const pair<long long, int>& a, const pair<long long, int>& b) { return a.first < b.first; } long long GCD(long long a, long long b) { if (b == 0) return a; return GCD(b, a % b); } int main() { {} long long a, b; cin >> a >> b; if (a == b) cout << a << endl; else cout << 2 << endl; return 0; }
#include <bits/stdc++.h> using namespace std; int main() { int x, y; cin >> x >> y; int i = x; int j = 2; i = x; int n = 2; int start; int rem; int prev_count = 1; int count = 1; int maxnum = n; while (n <= y) { if (y - x == 0) { maxnum = x; break; } rem = x % n; if (rem == n) break; if (rem != 0) { start = n - rem + x; j = start; } else j = x; prev_count = count; count = 0; while (j <= y) { count++; j = j + n; } if (prev_count > count) break; else if (count >= prev_count) maxnum = n; n = n + 1; } cout << maxnum << endl; return 0; }
#include <bits/stdc++.h> using namespace std; int main() { long long int r, l, i; cin >> l >> r; long long int t = 0, tw = 0; if (l == r) { cout << l; return 0; } cout << 2; return 0; }
#include <bits/stdc++.h> using namespace std; int f(int x, int d) { int res = 0; while (x) { x /= d; res += x; } return res; } bool is(int x) { if (x == 1 || x == 0) return false; if (x == 2) return true; if (x % 2 == 0) return false; for (int i = 3; i * i <= x; i += 2) if (x % i == 0) return false; return true; } int main() { ios_base::sync_with_stdio(0); cin.tie(0); int l, r; cin >> l >> r; if (l == r) { cout << l << "\n"; return 0; } cout << 2 << "\n"; }
#include <bits/stdc++.h> using namespace std; long double PI = 3.1415926535897932; const int N = 2e6 + 1000; long long int ans, ans1, sum, cnt, a[N], b[N]; long long int n, p, m, k; int main() { ios::sync_with_stdio(false), cin.tie(0), cout.tie(0); cout << setprecision(12) << fixed; cin >> n >> m; if (n == m) { cout << n; return 0; } cout << 2; return 0; }
#include <bits/stdc++.h> int main() { int a, b; scanf("%d%d", &a, &b); if (a == b) printf("%d\n", a); else printf("2\n"); return 0; }
#include <bits/stdc++.h> using namespace std; int main() { int a, b; scanf("%d %d", &a, &b); if (a == b) printf("%d\n", a); else puts("2"); return 0; }
#include <bits/stdc++.h> using namespace std; int main() { int a, b; cin >> a >> b; if (b == a) cout << b; else cout << 2; return 0; }
#include <bits/stdc++.h> using namespace std; const int N = 1e6 + 10; string s; bool mark[N]; int main() { ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL), cerr << ""; int r, l; cin >> r >> l; return (r == l ? cout << l : cout << 2), 0; }
#include <bits/stdc++.h> using namespace std; int main() { long long l, r; cin >> l >> r; if (l == r && l % 2) cout << l; else cout << 2; }
#include <bits/stdc++.h> int main() { long int l, r; scanf("%ld %ld", &l, &r); if (l == r) printf("%ld\n", r); else printf("2\n"); return 0; }
#include <bits/stdc++.h> using namespace std; signed main() { ios::sync_with_stdio(false); cin.tie(0); long long a, b; cin >> a >> b; if (a == b) cout << b; else cout << 2 << endl; }
#include <bits/stdc++.h> using namespace std; void solve() { int l, r; cin >> l >> r; cout << (l == r ? l : 2) << "\n"; } int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); solve(); return 0; }
#include <bits/stdc++.h> using namespace std; using ll = long long; using ld = long double; const ll kMod = (ll)1e9 + 7; int main(int argc, char **argv) { ios::sync_with_stdio(false); srand(time(0)); ll l, r; cin >> l >> r; ll ans = -1, cnt = -1; for (ll i = 2; i <= ceil(sqrt(r)); ++i) { ll a = l % i == 0 ? l : min(((l / i) + 1) * i, r); if (a % i != 0) continue; if ((r - a) / i > cnt) { ans = i; cnt = (r - a) / i; } } cout << (ans > 1 ? ans : r) << endl; }
#include <bits/stdc++.h> using namespace std; int main() { int m, n; int i, j; while (cin >> m >> n) { if (m != n) cout << 2 << endl; else cout << m << endl; } }
#include <bits/stdc++.h> int main() { long long m, n, i, j, c[10000], t, max; scanf("%lld%lld", &n, &m); if (m > 100000) { if (n == m) max = n; else max = 2; } else { for (i = 2; i <= 1000; i++) { c[i] = 0; for (j = n; j <= m; j++) { if (j % i == 0) { c[i]++; } } } t = c[2]; for (i = 2; i <= 1000; i++) { if (c[i] >= t) { t = c[i]; max = i; } } } printf("%lld\n", max); return 0; }
#include <bits/stdc++.h> using namespace std; int solve(int l, int r) { if (l == r) { return l; } else { return 2; } } void tests() { assert(solve(2, 2) == 2); assert(solve(3, 3) == 3); assert(solve(4, 4) == 4); assert(solve(7, 7) == 7); assert(solve(2, 3) == 2); assert(solve(3, 6) == 2); assert(solve(3, 4) == 2); } int main() { tests(); int l, r; while (cin >> l >> r) { cout << solve(l, r) << endl; } return 0; }
#include <bits/stdc++.h> int main() { int a, b, c; while (~scanf("%d%d", &a, &b)) { if (a == b) { printf("%d\n", a); } else { printf("2\n"); } } return 0; }
#include <bits/stdc++.h> using namespace std; int main() { int a, b; cin >> a >> b; if (a == b) cout << a << endl; else cout << 2 << endl; return 0; }
#include <bits/stdc++.h> using namespace std; clock_t T; int main() { ios_base::sync_with_stdio(false); cout.tie(NULL); cin.tie(NULL); ; long long n, m; cin >> n >> m; if (n == m && n % 2) cout << n; else cout << 2; }
#include <bits/stdc++.h> using namespace std; int main() { long long l, r; cin >> l >> r; if (l == r && l % 2 != 0) cout << l; else cout << 2; return 0; }
#include <bits/stdc++.h> using namespace std; int vocala(char c) { if (c == 'a' || c == 'A' || c == 'e' || c == 'E' || c == 'i' || c == 'I' || c == 'o' || c == 'O' || c == 'u' || c == 'U') return 1; if (c == 'y' || c == 'Y') return 1; return 0; } int isprime(long long n) { if (n <= 1) return 0; if (n <= 3) return 1; if (n % 2 == 0 || n % 3 == 0) return 0; for (int i = 5; i * i <= n; i = i + 6) if (n % i == 0 || n % (i + 2) == 0) return 0; return 1; } int isfibo(long long n) { long long a = 5 * n * n + 4; long long b = a - 8; if (sqrt(a) == int(sqrt(a)) || sqrt(b) == int(sqrt(b))) return 1; return 0; } int gcd(long long a, long long b) { long long r; while (b) { r = a % b; a = b; b = r; } return a; } ifstream in("input.txt"); ofstream out("output.txt"); long long const nrmax = 1e18; int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); long long n, k; cin >> n >> k; if (n == k && n % 2 != 0) cout << n; else { cout << "2"; } in.close(); out.close(); return 0; }
#include <bits/stdc++.h> using namespace std; int main() { int l, r, a = 0, b = 0; cin >> l >> r; if (l == r) { cout << l << endl; } else { cout << "2" << endl; } }
#include <bits/stdc++.h> using namespace std; const long long mod = 1000000007; const long long inf = 1LL << 62; const long long mx = 100005; const double eps = 1e-10; long long dx[10] = {1, 0, -1, 0}; long long dy[10] = {0, -1, 0, 1}; long long power(long long a, long long b) { if (b == 0) return 1; long long x = power(a, b / 2); x = x * x; if (b % 2) x = x * a; return x; } long long bigmod(long long a, long long b) { if (b == 0) return 1; long long x = bigmod(a, b / 2) % mod; x = (x * x) % mod; if (b % 2) x = (x * a) % mod; return x; } long long Set(long long N, long long pos) { return N = N | (1LL << pos); } long long reset(long long N, long long pos) { return N = N & ~(1LL << pos); } bool check(long long N, long long pos) { return (bool)(N & (1LL << pos)); } int main() { long long tst, a, b, c, k, n, m, res = 0, ans = 0, t = 0; scanf("%lld", &a), scanf("%lld", &b); if (a == b) { cout << b << "\n"; return 0; } cout << 2 << "\n"; return 0; }
#include <bits/stdc++.h> int main() { int i, j, n, swapped, temp, a, b, p = 0, q = 0; scanf(" %d %d", &a, &b); a == b ? printf("%d", a) : puts("2"); return 0; }
#include <bits/stdc++.h> using namespace std; int main() { int l, r; cin >> l >> r; cout << (l == r ? l : 2); }
#include <bits/stdc++.h> using namespace std; vector<pair<long long, long long>> v, d; long long ans; int main() { int l, r; cin >> l >> r; if (l % 3 == 0 and l + 3 == r) { cout << 3; return 0; } if (l == r) { cout << l; return 0; } cout << 2; return 0; }
#include <bits/stdc++.h> using namespace std; signed main() { int a, b; cin >> a >> b; if (a == b) cout << a << endl; else cout << 2 << endl; }
#include <bits/stdc++.h> using namespace std; int main() { int l, r; cin >> l >> r; int maxi = 0, ind = 2; bool d = false; if (r == l) { cout << r; return 0; } for (int j = 2; j <= l; j++) { if ((r / j) - ((l - 1) / j) > maxi) { maxi = (r / j) - ((l - 1) / j); ind = j; d = true; } else if (d) break; } cout << ind; }
#include <bits/stdc++.h> using namespace std; int max(int x, int y) { return x > y ? x : y; } int main() { int x, y; cin >> x >> y; if (x == y) printf("%d\n", x); else printf("2\n"); }
#include <bits/stdc++.h> using namespace std; int main() { int m, n; cin >> m >> n; if (m == n) cout << m << endl; else cout << 2 << endl; }
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); int l, r; cin >> l >> r; if (l == r) { cout << l; return 0; } cout << "2"; }