text
stringlengths
49
983k
#include <bits/stdc++.h> using namespace std; const double PI = acos(-1.0); template <class T> void Read(T &x) { char c; bool f = 0; while (c = getchar(), c != EOF) if (c == '-') f = 1; else if (c >= '0' && c <= '9') { x = c - '0'; while (c = getchar(), c >= '0' && c <= '9') x = x * 10 + c - '0'; ungetc(c, stdin); if (f) x = -x; return; } } namespace arr { inline int lowbit(int x) { return x & (-x); } template <class T> inline void arrUpdate(T *c, int x, T d, int N) { while (x <= N) { c[x] += d; x += lowbit(x); } } template <class T> inline T arrGetsum(T *c, int x) { T ret = 0; while (x) { ret += c[x]; x -= lowbit(x); } return ret; } } // namespace arr namespace Polynomial { namespace FFT { struct cplx { double a, b; cplx() {} cplx(double a, double b = 0) : a(a), b(b) {} inline cplx operator+(const cplx &x) const { return cplx(a + x.a, b + x.b); } inline cplx operator-(const cplx &x) const { return cplx(a - x.a, b - x.b); } inline cplx operator*(const cplx &x) const { return cplx(a * x.a - b * x.b, a * x.b + b * x.a); } inline cplx &operator*=(const cplx &x) { return *this = *this * x; } inline double sqr(double x) const { return x * x; } inline cplx operator/(const cplx &x) const { double t = sqr(x.a) + sqr(x.b); return cplx((a * x.a + b * x.b) / t, (b * x.a - a * x.b) / t); } inline cplx operator/=(const cplx &x) { return *this = *this / x; } }; void FFT(cplx *a, int n, int type) { for (int i = 1, j = 0; i < n; i++) { for (int t = n; j ^= (t >>= 1), (~j) & t;) ; if (i < j) swap(a[i], a[j]); } cplx x, y; for (int i = 1; i < n; i <<= 1) { cplx w1(cos(PI / i), sin(type * PI / i)); for (int j = 0; j < n; j += i << 1) { cplx w(1, 0); for (int k = 0; k < i; k++) { x = a[j + k], y = w * a[j + k + i]; a[j + k] = x + y, a[j + k + i] = x - y; w *= w1; } } } if (type == -1) { for (int i = 0; i < n; i++) a[i].a /= n, a[i].b /= n; } } void Multi(cplx *a, cplx *b, int n, int m) { m += n; for (n = 1; n <= m; n <<= 1) ; FFT(a, n, 1), FFT(b, n, 1); for (int i = 0; i < n; i++) a[i] *= b[i]; FFT(a, n, -1); } } // namespace FFT namespace NTT { inline int mypow(int x, int k) { int ret = 1; while (k) { if (k & 1) ret = 1LL * ret * x % (119 * (1 << 23) + 1); x = 1LL * x * x % (119 * (1 << 23) + 1); k >>= 1; } return ret; } void NTT(int *a, int n, int type) { for (int i = 1, j = 0; i < n; i++) { for (int t = n; j ^= (t >>= 1), (~j) & t;) ; if (i < j) swap(a[i], a[j]); } int x, y; for (int i = 1; i < n; i <<= 1) { int w1 = mypow(3, ((119 * (1 << 23) + 1) - 1) / (i << 1)); for (int j = 0; j < n; j += i << 1) { int w = 1; for (int k = 0; k < i; k++) { x = a[j + k], y = 1LL * w * a[j + k + i] % (119 * (1 << 23) + 1); a[j + k] = (x + y) % (119 * (1 << 23) + 1), a[j + k + i] = (x - y + (119 * (1 << 23) + 1)) % (119 * (1 << 23) + 1); w = 1LL * w * w1 % (119 * (1 << 23) + 1); } } } if (type == -1) { reverse(a + 1, a + n); long long inv = mypow(n, (119 * (1 << 23) + 1) - 2); for (int i = 0; i < n; i++) a[i] = 1LL * a[i] * inv % (119 * (1 << 23) + 1); } } void Multi(int *a, int *b, int n, int m) { m += n; for (n = 1; n <= m; n <<= 1) ; NTT(a, n, 1), NTT(b, n, 1); for (int i = 0; i < n; i++) a[i] = 1LL * a[i] * b[i] % (119 * (1 << 23) + 1); NTT(a, n, -1); } } // namespace NTT namespace FWT { void Xor(int *f, int n) { int S = 1 << n; for (int i = 1; i < S; i <<= 1) for (int j = 1; j < S; j++) if (j & i) f[j] += f[j ^ i]; } void iXor(int *f, int n) { int S = 1 << n; for (int i = 1; i < S; i <<= 1) for (int j = 1; j < S; j++) if (j & i) f[j] -= f[j ^ i]; } } // namespace FWT } // namespace Polynomial int ans, x, c[16] = {1, 0, 0, 0, 1, 0, 1, 0, 2, 1, 1, 2, 0, 1, 0, 0}; int main() { Read(x); if (!x) ans = c[0]; while (x) { ans += c[x & 15]; x >>= 4; } printf("%d\n", ans); return 0; }
#include <bits/stdc++.h> using namespace std; int n, x, ind = 1, ans = 0; char a[20], h[] = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F'}; int main() { cin >> x; if (x == 0) { cout << "1" << endl; return 0; } while (x) { a[ind++] = h[(x % 16)]; x /= 16; } for (int i = ind - 1; i >= 1; i--) { if (a[i] == '0' || a[i] == '4' || a[i] == '6' || a[i] == '9' || a[i] == 'A' || a[i] == 'D') ans++; if (a[i] == '8' || a[i] == 'B') ans += 2; } cout << ans << endl; return 0; }
#include <bits/stdc++.h> using namespace std; string transform(int x, int y, string s) { string res = ""; int sum = 0; for (int i = 0; i < s.length(); ++i) { if (s[i] == '-') continue; if (s[i] >= '0' && s[i] <= '9') { sum = sum * x + s[i] - '0'; } else { sum = sum * x + s[i] - 'A' + 10; } } while (sum) { char tmp = sum % y; sum /= y; if (tmp <= 9) { tmp += '0'; } else { tmp = tmp - 10 + 'A'; } res = tmp + res; } if (res.length() == 0) res = "0"; if (s[0] == '-') res = '-' + res; return res; } int b[16] = {1, 0, 0, 0, 1, 0, 1, 0, 2, 1, 1, 2, 0, 1, 0, 0}; int main() { string s; while (cin >> s) { string res = transform(10, 16, s); int len = res.length(); long long ans = 0; for (int i = 0; i < len; i++) { if (res[i] <= '9' && res[i] >= '0') ans += b[res[i] - '0']; else ans += b[res[i] - 'A' + 10]; } cout << ans << endl; } return 0; }
#include <bits/stdc++.h> int main() { int num = 0; int a[100]; 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) { printf("1\n"); return 0; } while (num > 0) { yushu = num % 16; a[i++] = yushu; num = num / 16; } int output = 0; for (i = i - 1; i >= 0; i--) { m = a[i]; if (hex[m] == '0') output++; if (hex[m] == '4') output++; if (hex[m] == '6') output++; if (hex[m] == '8') output += 2; if (hex[m] == '9') output++; if (hex[m] == 'A') output++; if (hex[m] == 'B') output += 2; if (hex[m] == 'D') output++; } printf("%d\n", output); }
#include <bits/stdc++.h> using namespace std; int deepdarkfantasy[16] = {1, 0, 0, 0, 1, 0, 1, 0, 2, 1, 1, 2, 0, 1}; int main(void) { int x, res = 0; scanf("%d", &x); if (!x) { printf("1"); return 0; } while (x) { res += deepdarkfantasy[x & 15]; x >>= 4; } printf("%d", res); return 0; }
#include <bits/stdc++.h> int a[] = {1, 0, 0, 0, 1, 0, 1, 0, 2, 1, 1, 2, 0, 1, 0, 0}; int n, ans; int main() { scanf("%d", &n); if (n == 0) { return printf("1\n"), 0; } while (n) { ans += a[n % 16]; n /= 16; } printf("%d\n", ans); return 0; }
#include <bits/stdc++.h> using namespace std; int w[23], wn = 0; int c[] = {1, 0, 0, 0, 1, 0, 1, 0, 2, 1, 1, 2, 0, 1, 0, 0}; int main() { int s; cin >> s; if (s == 0) { puts("1"); return 0; } while (s) { w[++wn] = s % 16; s /= 16; } int ans = 0; for (int i = 1; i <= wn; ++i) ans += c[w[i]]; cout << ans; }
#include <bits/stdc++.h> using namespace std; inline int read() { int x = 0, f = 1; char ch = getchar(); while (!(ch >= '0' && ch <= '9')) { if (ch == '-') f = -1; ch = getchar(); } while (ch >= '0' && ch <= '9') { x = x * 10 + (ch - '0'); ch = getchar(); } return x * f; } const int P[16] = {1, 0, 0, 0, 1, 0, 1, 0, 2, 1, 1, 2, 0, 1, 0, 0}; int main() { int n = read(); int ans = 0; do { ans += P[n % 16]; n /= 16; } while (n); printf("%d\n", ans); return 0; }
#include <bits/stdc++.h> using namespace std; int val[300]; int calc(int x) { if (x == 0) return 1; int ret = 0; while (x) { int d = x % 16; x /= 16; char c; if (d < 10) c = '0' + d; else c = 'A' + d - 10; ret += val[c]; } return ret; } int main() { val['0'] = 1; val['1'] = 0; val['2'] = 0; val['3'] = 0; val['4'] = 1; val['5'] = 0; val['6'] = 1; val['7'] = 0; val['8'] = 2; val['9'] = 1; val['A'] = 1; val['B'] = 2; val['C'] = 0; val['D'] = 1; val['E'] = 0; val['F'] = 0; int x, i; scanf("%d", &x); cout << calc(x) << '\n'; }
#include <bits/stdc++.h> using namespace std; int a[16] = {1, 0, 0, 0, 1, 0, 1, 0, 2, 1, 1, 2, 0, 1, 0, 0}; int main() { ios::sync_with_stdio(0); int n, ans = 0; cin >> n; if (n == 0) ans++; while (n) { ans += a[n % 16]; n /= 16; } cout << ans << endl; return 0; }
#include <bits/stdc++.h> using namespace std; long long n, m, ans = 0; inline void change(long long x) { if (x == 0) { ans = 1; return; } while (x > 0) { long long ret = x % 16; switch (ret) { case 0: { ans += 1; break; } case 1: { break; } case 2: { break; } case 3: { break; } case 4: { ans += 1; break; } case 5: { break; } case 6: { ans += 1; break; } case 7: { break; } case 8: { ans += 2; break; } case 9: { ans += 1; break; } case 10: { ans += 1; break; } case 11: { ans += 2; break; } case 12: { break; } case 13: { ans += 1; break; } case 14: { break; } case 15: { break; } } x = x / 16; } return; } int main() { cin >> n; change(n); cout << ans << endl; return 0; }
#include <bits/stdc++.h> constexpr int a[] = {1, 0, 0, 0, 1, 0, 1, 0, 2, 1, 1, 2, 0, 1, 0, 0}; int f(int n) { return a[n % 16] + (n >= 16 ? f(n >> 4) : 0); } int main(void) { int n; std::cin >> n; std::cout << f(n); return 0; }
#include <bits/stdc++.h> using namespace std; int a[1001]; int k[16] = {1, 0, 0, 0, 1, 0, 1, 0, 2, 1, 1, 2, 0, 1, 0, 0}; int main() { int n, ans = 0, w = 0; cin >> n; if (n == 0) { cout << 1; return 0; } while (n > 0) { a[w] = n % 16; n /= 16; w++; } for (int i = 0; i < w; i++) ans += k[a[i]]; cout << ans; return 0; }
#include <bits/stdc++.h> using namespace std; const int MAX = 505; int n; int a[] = {1, 0, 0, 0, 1, 0, 1, 0, 2, 1, 1, 2, 0, 1, 0, 0}; int cnt; int main() { scanf("%d", &n); if (n == 0) { printf("1\n"); return 0; } while (n) { int m = n % 16; n /= 16; cnt += a[m]; } printf("%d\n", cnt); }
#include <bits/stdc++.h> char x[10]; int main() { int a, d = 0, ans = 0; ; std::cin >> a; if (a == 0) return std::cout << '1', 0; while (a) { int t = (a & 15); if (t < 10) x[++d] = t + '0'; else x[++d] = t - 10 + 'A'; a >>= 4; } for (int i = 1; i <= d; ++i) { if (x[i] == '0' || x[i] == '4' || x[i] == '6' || x[i] == '9' || x[i] == 'A' || x[i] == 'D') ++ans; if (x[i] == '8' || x[i] == 'B') ans += 2; } std::cout << ans; return 0; }
#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(false); 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 holes; void search(int now) { if (now == 6) { ++holes; } else if (now == 8) { holes += 2; } else if (now == 9) { ++holes; } else if (now == 10) { ++holes; } else if (now == 11) { holes += 2; } else if (now == 13) { ++holes; } else if (now == 0) { ++holes; } else if (now == 4) { ++holes; } } int main() { long long n; int now; scanf("%lld", &n); if (n == 0) { holes = 1; } while (n > 0) { now = n % 16; search(now); n /= 16; } printf("%d\n", holes); return 0; }
#include <bits/stdc++.h> using namespace std; int main() { int arr[] = {1, 0, 0, 0, 1, 0, 1, 0, 2, 1, 1, 2, 0, 1, 0, 0}; int a; cin >> a; if (a == 0) return 0 * puts("1"); int ans = 0; while (a > 0) { ans += arr[a % 16]; a /= 16; } cout << ans; return 0; }
#include <bits/stdc++.h> using namespace std; int n; char p[] = {"1000101021120100"}; int main() { cin >> n; if (!n) { puts("1"); return 0; } int q = 0; while (n) q += p[n % 16] - 48, n /= 16; cout << q << "\n"; }
#include <bits/stdc++.h> using namespace std; int n, k; int 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) { do { k += a[n % 16]; n /= 16; } while (n != 0); cout << k << '\n'; } else { cout << 1 << '\n'; } return 0; }
#include <bits/stdc++.h> using namespace std; int main() { int n, cont = 0, resto; scanf("%d", &n); if (n == 0) cont = 1; while (n) { resto = n % 16; if (resto == 10 || resto == 13 || resto == 4 || resto == 6 || resto == 9 || resto == 0) cont++; else if (resto == 11 || resto == 8) cont += 2; n /= 16; } cout << cont << endl; return 0; }
#include <bits/stdc++.h> int main() { long long int x, y, result = 0; scanf("%I64d", &x); if (x == 0) printf("1"); else { while (x) { y = x % 16; if (y == 0 || y == 4 || y == 6 || y == 9 || y == 10 || y == 13) { result++; } if (y == 8 || y == 11) { result += 2; } x /= 16; } printf("%d", result); } return 0; }
#include <bits/stdc++.h> using namespace std; int arr[] = {1, 0, 0, 0, 1, 0, 1, 0, 2, 1, 1, 2, 0, 1, 0, 0}; int main() { int n, num = 0; cin >> n; if (!n) cout << "1"; else { while (n) num += arr[n % 16], n /= 16; cout << num; } }
#include <bits/stdc++.h> using namespace std; int n, ans = 0; int main() { scanf("%d", &n); while (n >= 16) { if (n % 16 == 0) ans += 1; if (n % 16 == 4) ans += 1; if (n % 16 == 6) ans += 1; if (n % 16 == 8) ans += 2; if (n % 16 == 9) ans += 1; if (n % 16 == 10) ans += 1; if (n % 16 == 11) ans += 2; if (n % 16 == 13) ans += 1; n /= 16; } if (n == 0) ans += 1; if (n == 4) ans += 1; if (n == 6) ans += 1; if (n == 8) ans += 2; if (n == 9) ans += 1; if (n == 10) ans += 1; if (n == 11) ans += 2; if (n == 13) ans += 1; printf("%d\n", ans); return 0; }
#include <bits/stdc++.h> using namespace std; long long N; int ans; int m[] = {1, 0, 0, 0, 1, 0, 1, 0, 2, 1, 1, 2, 0, 1, 0, 0}; int32_t main() { ios_base::sync_with_stdio(false); if (fopen("cf784b.in", "r")) { freopen("cf784b.in", "r", stdin); freopen("cf784b.out", "w", stdout); } cin >> N; if (N == 0) { cout << "1\n"; return 0; } while (N > 0) { long long x = N % 16; ans += m[x]; N /= 16; } cout << ans << '\n'; return 0; }
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; if (n == 0) { cout << 1; return 0; } int res = 0; while (n > 0) { int x = n % 16; if (x == 0) res++; if (x == 4) res++; if (x == 6) res++; if (x == 8) res += 2; if (x == 9) res++; if (x == 10) res++; if (x == 11) res += 2; if (x == 13) res++; n /= 16; } cout << res << endl; return 0; }
#include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(false); cin.tie(0); long long n, i, j, k, ans; vector<int> c = {1, 0, 0, 0, 1, 0, 1, 0, 2, 1, 1, 2, 0, 1, 0, 0}; cin >> n; ans = 0; if (n == 0) ans = 1; while (n > 0) { ans += c[n % 16]; n /= 16; } cout << ans << "\n"; return 0; }
#include <bits/stdc++.h> using namespace std; int main() { int input, sum = 0; cin >> input; stringstream s; s << hex << input; string str; s >> str; for (int i = 0; i < str.size(); i++) { if (str[i] == '0') sum++; if (str[i] == '4') sum++; if (str[i] == '6') sum++; if (str[i] == '8') sum += 2; if (str[i] == '9') sum++; if (str[i] == 'a') sum++; if (str[i] == 'b') sum += 2; if (str[i] == 'd') sum++; } cout << sum << endl; return 0; }
#include <bits/stdc++.h> using namespace std; int main() { map<int, int> s; s['0'] = 1, s['4'] = 1, s['6'] = 1, s['8'] = 2, s['9'] = 1, s['A'] = 1, s['B'] = 2, s['D'] = 1; unsigned int x, res = 0; char a[100]; scanf("%u", &x), sprintf(a, "%X", x); for (int p = 0; a[p]; ++p) res += s[a[p]]; printf("%u\n", res); }
#include <bits/stdc++.h> int q[] = {1, 0, 0, 0, 1, 0, 1, 0, 2, 1, 1, 2, 0, 1, 0, 0}, x, ans; int main() { scanf("%d", &x); if (x == 0) { printf("1\n"); return 0; } while (x) { ans += q[x % 16]; x >>= 4; } printf("%d\n", ans); return 0; }
#include <bits/stdc++.h> int main() { int n; std::cin >> n; if (n == 0) { puts("1"); return 0; } int result = 0; while (n) { int x = n % 16; n /= 16; int a[] = {1, 0, 0, 0, 1, 0, 1, 0, 2, 1, 1, 2, 0, 1, 0, 0}; result += a[x]; } std::cout << result << std::endl; }
#include <bits/stdc++.h> long long n; int aa[] = {1, 0, 0, 0, 1, 0, 1, 0, 2, 1, 1, 2, 0, 1, 0, 0}; int main() { int ans = 0; std::cin >> n; if (!n) ans = 1; while (n) { ans += aa[n % 16]; n /= 16; } std::cout << ans; return 0; }
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; int cnt = 0; do { 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; } while (n); cout << cnt; return 0; }
#include <bits/stdc++.h> using namespace std; long long n; int cnt[16]; int main() { scanf("%I64d", &n); do { ++cnt[n & 0xF]; n >>= 0x04; } while (n); printf("%d\n", cnt[0] + cnt[4] + cnt[6] + 2 * cnt[8] + cnt[9] + cnt[10] + 2 * cnt[11] + cnt[13]); return 0; }
#include <bits/stdc++.h> using namespace std; char s[100]; int i; void z(int n, int k) { int t; i = 0; while (true) { if (n == 0) break; else { i++; t = n % k; n = n / k; if (t >= 10) t = t + 55; else t = t + 48; s[i] = t; } } } int main() { int give = 0; int w; cin >> w; if (w == 0) { cout << 1; return 0; } z(w, 16); for (int j = i; j >= 1; j--) if (s[j] == '0' || s[j] == '4' || s[j] == '6' || s[j] == '9' || s[j] == 'A' || s[j] == 'D') give++; else if (s[j] == '8' || s[j] == 'B') give += 2; cout << give; return 0; }
#include <bits/stdc++.h> using namespace std; int main() { int n, c = 0; cin >> n; if (!n) c++; while (n) { int x = n % 16; n /= 16; if (x == 0 || x == 4 || x == 6 || x == 9 || x == 10 || x == 13) c += 1; if (x == 8 || x == 11) c += 2; } cout << c; }
#include <bits/stdc++.h> using namespace std; int n, ans; int a[] = {1, 0, 0, 0, 1, 0, 1, 0, 2, 1, 1, 2, 0, 1, 0, 0}; int main() { scanf("%d", &n); if (n == 0) { puts("1"); return 0; } while (n) { ans += a[n % 16]; n /= 16; } printf("%d\n", ans); return 0; }
#include <bits/stdc++.h> using namespace std; const int lps[] = {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 == 0) puts("1"); else { int c = 0; for (; n > 0; n /= 16) c += lps[n % 16]; printf("%d\n", c); } return 0; }
#include <bits/stdc++.h> int n, r, a[] = {1, 0, 0, 0, 1, 0, 1, 0, 2, 1, 1, 2, 0, 1, 0, 0}; int main() { scanf("%d", &n); for (r = !n; n; n >>= 4) r += a[n & 15]; printf("%d", r); }
#include <bits/stdc++.h> using namespace std; int main() { long long n; cin >> n; string s = ""; if (n == 0) s.push_back('0'); while (n) { long long q = n % 16; n /= 16; if (q < 10) s.push_back(q + '0'); else { s.push_back((q - 10) + 'A'); } } long long ans = 0; for (int i = 0; i < s.size(); i++) { if (s[i] == '0') ans++; if (s[i] == '4') ans++; if (s[i] == '6') ans++; if (s[i] == '8') ans += 2; if (s[i] == '9') ans++; if (s[i] == 'A') ans++; if (s[i] == 'B') ans += 2; if (s[i] == 'D') ans++; } cout << ans; return 0; }
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(nullptr); string digits[16] = {"0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "A", "B", "C", "D", "E", "F"}; int dec; int k = 0; cin >> dec; string snum; do { snum.insert(0, digits[dec % 16]); dec /= 16; } while (dec != 0); for (int i = 0; i < snum.size(); ++i) { if (snum[i] == '0') k++; if (snum[i] == '4') k++; if (snum[i] == '6') k++; if (snum[i] == '8') k = k + 2; if (snum[i] == '9') k++; if (snum[i] == 'A') k++; if (snum[i] == 'B') k = k + 2; if (snum[i] == 'D') k++; } cout << k << endl; }
#include <bits/stdc++.h> using namespace std; int main() { long long m, n; vector<int> v; char s[] = "0123456789ABCDEF"; cin >> n; v.clear(); if (n == 0) v.push_back(0); while (n != 0) { v.push_back(n % 16); n = n / 16; } long long ans = 0; vector<int>::reverse_iterator rit; for (rit = v.rbegin(); rit != v.rend(); rit++) { if (s[*rit] == '0') ans++; else if (s[*rit] == '6') ans++; else if (s[*rit] == '4') ans++; else if (s[*rit] == '8') ans += 2; else if (s[*rit] == '9') ans++; else if (s[*rit] == 'A') ans++; else if (s[*rit] == 'B') ans += 2; else if (s[*rit] == 'D') ans++; else if (s[*rit] == '0') ans++; } cout << ans << endl; return 0; }
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; stringstream stream; stream << hex << n; string result(stream.str()); for (auto &x : result) x = toupper(x); map<char, int> mp; mp['0'] = 1; mp['4'] = 1; mp['6'] = 1; mp['8'] = 2; mp['9'] = 1; mp['A'] = 1; mp['B'] = 2; mp['D'] = 1; int ans = 0; for (auto x : result) ans += mp[x]; cout << ans << "\n"; return 0; }
#include <bits/stdc++.h> using namespace std; pair<pair<int, int>, int> pii[123456]; int main() { long long m, n; vector<int> v; char s[] = "0123456789ABCDEF"; cin >> n; v.clear(); if (n == 0) v.push_back(0); while (n != 0) { v.push_back(n % 16); n = n / 16; } long long ans = 0; vector<int>::iterator rit; for (rit = v.begin(); rit != v.end(); rit++) { if (s[*rit] == '0') ans++; else if (s[*rit] == '6') ans++; else if (s[*rit] == '4') ans++; else if (s[*rit] == '8') ans += 2; else if (s[*rit] == '9') ans++; else if (s[*rit] == 'A') ans++; else if (s[*rit] == 'B') ans += 2; else if (s[*rit] == 'D') ans++; else if (s[*rit] == '0') ans++; } cout << ans << endl; return 0; }
#include <bits/stdc++.h> using namespace std; template <typename T> void sci(T& t) { cin >> t; } template <typename T, typename... Ts> void sci(T& t, Ts&... ts) { sci(t); sci(ts...); } int32_t main() { cin.tie(nullptr); cout.tie(nullptr); ios_base::sync_with_stdio(false); int64_t n; cin >> n; if (n == 0) return cout << 1, 0; vector<int64_t> a(16, 0); a[0] = a[4] = a[6] = a[9] = a[10] = a[13] = 1; a[8] = a[11] = 2; int64_t ans = 0; while (n > 0) { int64_t num = n % 16; n /= 16; ans += a[num]; } cout << ans; return 0; }
#include <bits/stdc++.h> using namespace std; int main() { long long n; cin >> n; if (n < 16) { if ((n == 10) || (n == 13) || (n == 4) || (n == 6) || (n == 9) || (n == 0)) { cout << 1 << endl; return 0; } if ((n == 11) || (n == 8)) { cout << 2 << endl; return 0; } else { cout << 0 << endl; return 0; } } int sum = 0; while (n >= 16) { if ((n % 16 == 10) || (n % 16 == 13) || (n % 16 == 4) || (n % 16 == 6) || (n % 16 == 9) || (n % 16 == 0)) { sum++; } if ((n % 16 == 11) || (n % 16 == 8)) { sum += 2; } n = n / 16; } if ((n == 10) || (n == 13) || (n == 4) || (n == 6) || (n == 9) || (n == 0)) { sum++; } if ((n == 11) || (n == 8)) { sum += 2; } cout << sum << endl; return 0; }
#include <bits/stdc++.h> using namespace std; int r[20] = {1, 0, 0, 0, 1, 0, 1, 0, 2, 1, 1, 2, 0, 1, 0, 0, 0}, a[100], cnt; int main() { long long n; cin >> n; if (!n) cnt = 1; while (n) { cnt += r[n % 16]; n /= 16; } cout << cnt; return 0; }
#include <bits/stdc++.h> using namespace std; int a[21]; int main() { 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; int n, ans = 0; scanf("%d", &n); if (n == 0) return 0 * puts("1"); while (n) { ans += a[n % 16]; n /= 16; } printf("%d\n", ans); return 0; }
#include <bits/stdc++.h> using namespace std; const int LIMIT = 2000000000; int a[16] = {1, 0, 0, 0, 1, 0, 1, 0, 2, 1, 1, 2, 0, 1, 0, 0}; int ans; int main() { int n; scanf("%d", &n); if (n == 0) ans = 1; else while (n) ans += a[n % 16], n /= 16; printf("%d\n", ans); return 0; }
#include <bits/stdc++.h> using namespace std; int ans; int main() { int n; scanf("%d", &n); if (n == 0) { printf("%d", 1); return 0; } while (n) { int t = n % 16; if (t == 0 || t == 4 || t == 6 || t == 9 || t == 10 || t == 13) ++ans; if (t == 8 || t == 11) ans += 2; n /= 16; } printf("%d", ans); return 0; }
#include <bits/stdc++.h> using namespace std; int main() { long long a; cin >> a; if (a == 0) { cout << 1; return 0; } string ans; map<char, int> mp; mp['0'] = 1; mp['1'] = 0; mp['2'] = 0; mp['3'] = 0; mp['4'] = 1; mp['5'] = 0; mp['6'] = 1; mp['7'] = 0; mp['8'] = 2; mp['9'] = 1; mp['A'] = 1; mp['B'] = 2; mp['C'] = 0; mp['D'] = 1; mp['E'] = 0; mp['F'] = 0; while (a != 0) { int ost = a % 16; ans += (a % 16 < 10) ? to_string(a % 16) : ""; if (ost >= 10) { ans += (char)('A' + ost - 10); } a /= 16; } long long answ = 0; for (auto i : ans) { answ += mp[i]; } cout << answ; }
#include <bits/stdc++.h> using namespace std; int a[20] = {1, 0, 0, 0, 1, 0, 1, 0, 2, 1, 1, 2, 0, 1, 0, 0}; long long n; int main() { cin >> n; int ans = 0; if (n == 0) { cout << 1 << endl; return 0; } while (n != 0) { ans += (a[n % 16]); n /= 16; } cout << ans << endl; return 0; }
#include <bits/stdc++.h> using namespace std; const int NN = 50010; const int INF = 0x3f3f3f3f; const int MOD = 100000, STA = 8000010; const long long LNF = 1LL << 60; const double EPS = 1e-8; const double OO = 1e15; const int dx[4] = {-1, 0, 1, 0}; const int dy[4] = {0, 1, 0, -1}; const int day[13] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}; inline int sign(double x) { return (x > EPS) - (x < -EPS); } template <class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; } template <class T> T lcm(T a, T b) { return a / gcd(a, b) * b; } template <class T> inline T lcm(T a, T b, T d) { return a / d * b; } template <class T> inline T Min(T a, T b) { return a < b ? a : b; } template <class T> inline T Max(T a, T b) { return a > b ? a : b; } template <class T> inline T Min(T a, T b, T c) { return min(min(a, b), c); } template <class T> inline T Max(T a, T b, T c) { return max(max(a, b), c); } template <class T> inline T Min(T a, T b, T c, T d) { return min(min(a, b), min(c, d)); } template <class T> inline T Max(T a, T b, T c, T d) { return max(max(a, b), max(c, d)); } long long N, M, T; char A[101]; int main() { cin >> N; sprintf(A, "%x", N); int L = strlen(A); int ans = 0; for (int i = 0; i < L; i++) { if (A[i] == '0' || A[i] == 'a' || A[i] == 'd' || A[i] == '4' || A[i] == '6' || A[i] == '9') ans++; else if (A[i] == 'b' || A[i] == '8') ans += 2; } cout << ans << endl; return 0; }
#include <bits/stdc++.h> using namespace std; long long n; int a[] = {1, 0, 0, 0, 1, 0, 1, 0, 2, 1, 1, 2, 0, 1, 0, 0}; int main() { long long ans = 0; cin >> n; if (n == 0) { puts("1"); return 0; } while (n) { int x = n % 16; ans += a[x]; n /= 16; } cout << ans; }
#include <bits/stdc++.h> #pragma _attribute_((optimize("-O3"))) using namespace std; int main() { ios::sync_with_stdio(false); cin.tie(0); long long x; int res[17] = {1, 0, 0, 0, 1, 0, 1, 0, 2, 1, 1, 2, 0, 1, 0, 0, 0}; while (cin >> x) { int cont = 0; if (x == 0) cont = 1; while (x > 0) { int tmp = x % 16; cont += res[tmp]; x /= 16; } cout << cont << endl; } return 0; }
#include <bits/stdc++.h> int n, ans; int main() { scanf("%d", &n); if (n == 0) { printf("1"); return 0; } while (n) { int x = n % 16; if (x == 0 || x == 4 || x == 6 || x == 9 || x == 10 || x == 13) ++ans; if (x == 8 || x == 11) ans += 2; n /= 16; } printf("%d", ans); }
#include <bits/stdc++.h> using namespace std; vector<int> ans, fact; int main() { int n, i, ans = 0, a; cin >> n; if (n == 0) ans = 1; while (n != 0) { a = n % 16; n >>= 4; switch (a) { case 1: case 2: case 3: case 5: case 7: case 12: case 14: case 15: ans += 0; break; case 0: case 4: case 6: case 9: case 10: case 13: ans++; break; case 8: case 11: ans += 2; break; } } cout << ans; return 0; }
#include <bits/stdc++.h> using namespace std; int main() { int a; cin >> a; int ans = 0; if (a == 0) cout << 1 << endl; else { while (a) { int b = a % 16; if (b == 0 || b == 10 || b == 13 || b == 4 || b == 6 || b == 9) { ans++; } if (b == 11 || b == 8) { ans += 2; } a /= 16; } cout << ans << endl; } return 0; }
#include <bits/stdc++.h> using namespace std; const int MAXN = 50 + 10; const int MAXM = 1000 + 10; const int INF = 1000000001; const int MOD = 1000000007; int c[300]; int main(int argc, char* argv[]) { ios::sync_with_stdio(false); int a; c['0'] = c['4'] = c['6'] = c['9'] = c['a'] = c['d'] = 1; c['8'] = c['b'] = 2; cin >> a; stringstream str; str << hex << a; string s; str >> s; int ans = 0; for (int i = 0; i < s.length(); i++) ans += c[s[i]]; cout << ans << endl; return 0; }
#include <bits/stdc++.h> using namespace std; int cal(int k) { if (k == 0) return 1; if (k == 4) return 1; if (k == 6) return 1; if (k == 8) return 2; if (k == 9) return 1; if (k == 10) return 1; if (k == 11) return 2; if (k == 13) return 1; return 0; } int main() { long long n; cin >> n; if (n == 0) return !printf("1"); int ans = 0; while (n) { ans += cal(n % 16); n /= 16; } cout << ans; return 0; }
#include <bits/stdc++.h> using namespace std; int main(int argc, char **argv) { ios_base::sync_with_stdio(false); cin.tie(0), cout.tie(0), cout.precision(15); vector<int> tb(16, 0); tb[0] = 1; tb[4] = 1; tb[6] = 1; tb[8] = 2; tb[9] = 1; tb[10] = 1; tb[11] = 2; tb[13] = 1; int n; cin >> n; int res = 0; if (n == 0) { res = 1; } else { while (n > 0) { res += tb[n % 16]; n /= 16; } } cout << res << endl; 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; int s = 0; cin >> n; if (n == 0) { cout << 1; return 0; } else { while (n > 0) { s += v[n % 16]; n /= 16; } cout << s; } }
#include <bits/stdc++.h> using namespace std; const int maxn = 100000 + 10; 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); if (!n) { printf("1\n"); return 0; } int ans = 0; while (n) { ans += a[n % 16]; n /= 16; } printf("%d\n", ans); return 0; }
#include <bits/stdc++.h> using namespace std; int IN() { int c, f, x; while (!isdigit(c = getchar()) && c != '-') ; c == '-' ? (f = 1, x = 0) : (f = 0, x = c - '0'); while (isdigit(c = getchar())) x = (x << 1) + (x << 3) + c - '0'; return !f ? x : -x; } int x, res; void Work(int x) { if (x == 0 || x == 4 || x == 6 || x == 9 || x == 10 || x == 13) res++; if (x == 8 || x == 11) res += 2; } int main() { x = IN(); if (x == 0) { puts("1"); return 0; } for (; x; x /= 16) Work(x % 16); printf("%d\n", res); }
#include <bits/stdc++.h> using namespace std; int main() { int a; cin >> a; char s[30]; sprintf(s, "%X", a); int ans = 0; for (int(i) = (0); (i) < (strlen(s)); i++) { switch (s[i]) { case '4': case '6': case '9': case '0': case 'A': case 'D': ans++; break; case '8': case 'B': ans += 2; break; default: break; } } cout << ans; return 0; }
#include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(false); int n; cin >> n; stringstream ss; string s; ss << hex << n; ss >> s; int ats = 0; for (int i = 0; i < s.size(); i++) { if (s[i] == '0' || s[i] == '6' || s[i] == '9' || s[i] == 'a' || s[i] == 'd' || s[i] == '4') ats++; if (s[i] == 'b' || s[i] == '8') ats += 2; } cout << ats; }
#include <bits/stdc++.h> using namespace std; const long long mod = 1000000007; int main() { int n; int ans = 0; cin >> n; if (n == 0) ans++; while (n > 0) { int x = n % 16; n /= 16; if (x == 0 || x == 4 || x == 6 || x == 9 || x == 10 || x == 13) ans++; else if (x == 8 || x == 11) ans += 2; } cout << ans; }
#include <bits/stdc++.h> using namespace std; const int inf = 0x3f3f3f3f; const int mo = 1000000007; inline void gn(long long &x) { int sg = 1; char c; while (((c = getchar()) < '0' || c > '9') && c != '-') ; c == '-' ? (sg = -1, x = 0) : (x = c - '0'); while ((c = getchar()) >= '0' && c <= '9') x = x * 10 + c - '0'; x *= sg; } inline void gn(int &x) { long long t; gn(t); x = t; } inline void gn(unsigned long long &x) { long long t; gn(t); x = t; } inline void gn(double &x) { double t; scanf("%lf", &t); x = t; } inline void gn(long double &x) { double t; scanf("%lf", &t); x = t; } template <class T1, class T2> inline void gn(T1 &r, T2 &s) { gn(r), gn(s); } template <class T1, class T2, class T3> inline void gn(T1 &r, T2 &s, T3 &t) { gn(r), gn(s), gn(t); } template <class T1, class T2, class T3, class T4> inline void gn(T1 &r, T2 &s, T3 &t, T4 &u) { gn(r), gn(s), gn(t), gn(u); } inline void gs(char *s) { scanf("%s", s); } inline void gc(char &c) { while ((c = getchar()) > 126 || c < 33) ; } inline void pc(char c) { putchar(c); } const int DX[] = {1, 0, -1, 0}, DY[] = {0, 1, 0, -1}; long long powmod(long long a, long long b) { long long res = 1; a %= mo; for (; b; b >>= 1) { if (b & 1) res = res * a % mo; a = a * a % mo; } return res; } long long powmod(long long a, long long b, long long mo) { long long res = 1; a %= mo; for (; b; b >>= 1) { if (b & 1) res = res * a % mo; a = a * a % mo; } return res; } long long gcd(long long a, long long b) { return b ? gcd(b, a % b) : a; } const int N = 111111, M = 1111111; int l, m, n, t, C, ans; int A[] = {1, 0, 0, 0, 1, 0, 1, 0, 2, 1, 1, 2, 0, 1, 0, 0}; int main() { while (scanf("%d", &n) != EOF) { if (n == 0) { puts("1"); return 0; } for (; n; n /= 16) ans += A[n % 16]; printf("%d\n", ans); } return 0; }
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; if (n == 0) { cout << 1; return 0; } int res = 0; while (n) { int k = n % 16; n /= 16; switch (k) { case 1: case 2: case 3: case 5: case 7: case 12: case 14: case 15: break; case 0: case 4: case 6: case 9: case 10: case 13: res += 1; break; case 8: case 11: res += 2; } } cout << res; }
#include <bits/stdc++.h> using namespace std; int n, ans; int main() { scanf("%d", &n); if (n == 0) ans = 1; while (n) { int nn = n % 16; if (nn == 0 || nn == 4 || nn == 6 || nn == 9 || nn == 10 || nn == 13) ans++; if (nn == 8 || nn == 11) ans += 2; n /= 16; } printf("%d", ans); }
#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() { ios::sync_with_stdio(0); long long n; cin >> n; int ans = 0; ans += a[n % 16]; n /= 16; while (n) { ans += a[n % 16]; n /= 16; } cout << ans << endl; }
#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> 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; 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); if (n == 0) printf("%d\n", 1); else printf("%lld\n", getAns(n)); return 0; }
#include <bits/stdc++.h> using namespace std; int main(int argc, const char *argv[]) { int n, ans = 0; cin >> n; if (n == 0) { cout << 1 << endl; return 0; } while (n) { int t = n % 16; if (t == 0 || t == 10 || t == 13 || t == 4 || t == 6 || t == 9) { ans++; } if (t == 11 || t == 8) { ans += 2; } n /= 16; } cout << ans << endl; return 0; }
#include <bits/stdc++.h> using namespace std; int cnt[1000]; int main() { int a; char num[100]; cin >> a; sprintf(num, "%x", a); cnt['0'] = 1; cnt['4'] = 1; cnt['6'] = 1; cnt['8'] = 2; cnt['9'] = 1; cnt['a'] = 1; cnt['b'] = 2; cnt['d'] = 1; int ans = 0; char *p = num; while (*p) ans += cnt[*p++]; cout << ans << endl; return 0; }
#include <bits/stdc++.h> using namespace std; #pragma comment(linker, "/STACK:102400000,102400000") long long mul(long long a, long long b) { return (a * b) % (1000000007); } long long add(long long a, long long b) { return (a + b) % (1000000007); } long long sub(long long a, long long b) { return ((a - b) % (1000000007) + (1000000007)) % (1000000007); } void upd(long long &a, long long b) { a = (a % (1000000007) + b % (1000000007)) % (1000000007); } int read() { int x = 0, f = 1; char ch = getchar(); while (!isdigit(ch)) { if (ch == '-') f = -1; ch = getchar(); } while (isdigit(ch)) { x = x * 10 + ch - '0'; ch = getchar(); } return x * f; } int main() { long long n; cin >> n; char s[10000]; int h[10000]; sprintf(s, "%x", n); int ans = 0; h['0'] = 1; h['4'] = 1; h['6'] = 1; h['9'] = 1; h['8'] = 2; h['a'] = 1; h['d'] = 1; h['b'] = 2; for (int i = 0; i < strlen(s); i++) { ans += h[s[i]]; } cout << ans << endl; return 0; }
#include <bits/stdc++.h> using namespace std; string str = "0123456789ABCDEF"; int main() { map<char, int> mp; mp['0'] = 1; mp['1'] = 0; mp['2'] = 0; mp['3'] = 0; mp['4'] = 1; mp['5'] = 0; mp['6'] = 1; mp['7'] = 0; mp['8'] = 2; mp['9'] = 1; mp['A'] = 1; mp['B'] = 2; mp['C'] = 0; mp['D'] = 1; mp['E'] = 0; mp['F'] = 0; long long n; cin >> n; if (n == 0) { cout << 1 << endl; return 0; } string ans; while (n) { ans += str[n % 16]; n = n / 16; } int res = 0; for (int i = 0; i < ans.size(); i++) { res += mp[ans[i]]; } cout << res << endl; }
#include <bits/stdc++.h> using namespace std; template <class T> bool ckmin(T& a, const T& b) { return b < a ? a = b, 1 : 0; } template <class T> bool ckmax(T& a, const T& b) { return a < b ? a = b, 1 : 0; } int pct(int x) { return __builtin_popcount(x); } int bits(int x) { return 31 - __builtin_clz(x); } int fstTrue(function<bool(int)> first, int lo, int hi) { hi++; assert(lo <= hi); while (lo < hi) { int mid = (lo + hi) / 2; first(mid) ? hi = mid : lo = mid + 1; } return lo; } const long long MOD = 1e9 + 7; const int dx[8] = {1, 0, -1, 0, 1, 1, -1, -1}, dy[8] = {0, 1, 0, -1, -1, 1, -1, 1}; int gcd(int a, int b) { return b ? gcd(b, a % b) : a; } long long binpow(long long a, long long b) { long long res = 1; while (b) { if (b & 1) res = (res * a) % MOD; a = (a * a) % MOD; b >>= 1; } return res; } long long modInv(long long a) { return binpow(a, MOD - 2); } bool sortcol(const vector<long long>& v1, const vector<long long>& v2) { return v1[1] < v2[1]; } bool sortpair(const pair<int, int>& p1, const pair<int, int>& p2) { return p1.first < p2.first; } mt19937 rng((uint32_t)chrono::steady_clock::now().time_since_epoch().count()); uniform_int_distribution<long long unsigned> distribution(0, 10); 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"); } 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) { int first = 0; cerr << '{'; for (auto& i : x) cerr << (first++ ? "," : ""), __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...); } const int mxN = 2e5 + 5; int n; string decToHexa(int n) { char hexaDeciNum[100]; int i = 0; while (n != 0) { int temp = 0; temp = n % 16; if (temp < 10) { hexaDeciNum[i] = temp + 48; i++; } else { hexaDeciNum[i] = temp + 55; i++; } n = n / 16; } string ans; for (int j = i - 1; j >= 0; j--) ans += hexaDeciNum[j]; return ans; } void solve() { cin >> n; string ans = decToHexa(n); set<int> s1 = {'0', '4', '6', '9', 'A', 'D'}, s2 = {'8', 'B'}; int res = 0; for (int i = (0); i < (ans.length()); i++) { if (s1.count(ans[i])) res++; if (s2.count(ans[i])) res += 2; } cout << (ans.length() ? res : 1) << "\n"; } int main() { cin.tie(0)->sync_with_stdio(0); int tc = 1; while (tc--) solve(); }
#include <bits/stdc++.h> using namespace std; const long long mod = 1000000007; int a[18] = {1, 0, 0, 0, 1, 0, 1, 0, 2, 1, 1, 2, 0, 1, 0, 0}; long long n; int main() { cin >> n; if (n == 0) { cout << 1 << endl; return 0; } int res = 0; while (n != 0) { int m = n % 16; n /= 16; res += a[m]; } cout << res << endl; return 0; }
#include <bits/stdc++.h> using namespace std; const int N = 1e6 + 5; long long n; int main() { int ans = 0; cin >> n; if (n == 0) { cout << 1 << endl; return 0; } while (n) { int temp = n % 16; if (temp == 4 || temp == 6 || temp == 9 || temp == 0 || temp == 10 || temp == 13) ans++; else if (temp == 8 || temp == 11) ans += 2; n /= 16; } cout << ans << endl; }
#include <bits/stdc++.h> using namespace std; int main() { map<char, int> b = {{'0', 1}, {'4', 1}, {'6', 1}, {'8', 2}, {'9', 1}, {'A', 1}, {'B', 2}, {'D', 1}}; long long x; string hex; cin >> x; int ans = 0; if (x == 0) { cout << 1; return 0; } while (x) { if (x % 16 < 10) hex += (char)(x % 16) + '0'; if (x % 16 == 10) hex += 'A'; if (x % 16 == 11) hex += 'B'; if (x % 16 == 12) hex += 'C'; if (x % 16 == 13) hex += 'D'; if (x % 16 == 14) hex += 'E'; if (x % 16 == 15) hex += 'F'; x /= 16; } for (int i = 0; i < hex.size(); ++i) ans += b[hex[i]]; cout << ans; }
#include <bits/stdc++.h> using namespace std; int n, t; int c[] = {1, 0, 0, 0, 1, 0, 1, 0, 2, 1, 1, 2, 0, 1, 0, 0}; int main() { cin >> n; if (!n) t++; while (n) { t += c[n % 16]; n /= 16; } cout << t; return 0; }
#include <bits/stdc++.h> int main() { int a; scanf("%d", &a); int ans = 0; if (!a) ++ans; while (a) { if (a % 16 == 0) ++ans; else if (a % 16 == 4) ++ans; else if (a % 16 == 6) ++ans; else if (a % 16 == 8) ans += 2; else if (a % 16 == 9) ++ans; else if (a % 16 == 10) ++ans; else if (a % 16 == 11) ans += 2; else if (a % 16 == 13) ++ans; a /= 16; } printf("%d\n", ans); return 0; }
#include <bits/stdc++.h> using namespace std; int a[16] = {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; return 0; } int ans = 0; while (n != 0) { ans += (a[n % 16]); n = n / 16; } cout << ans; return 0; }
#include <bits/stdc++.h> int a[16] = {1, 0, 0, 0, 1, 0, 1, 0, 2, 1, 1, 2, 0, 1, 0, 0}; int main() { int n, ans = 0; scanf("%d", &n); if (n == 0) { printf("1\n"); return 0; } while (n) { ans += a[n % 16]; n /= 16; } printf("%d\n", ans); return 0; }
#include <bits/stdc++.h> using namespace std; int main() { long int decnum, rem, quot; int i = 1, j, temp; cin >> decnum; quot = decnum; stringstream ss; ss << std::hex << decnum; string hexdecnum(ss.str()); int x = 0; for (int p = 0; p < hexdecnum.length(); p++) { if (hexdecnum[p] == '0') x += 1; else if (hexdecnum[p] == '4') x += 1; else if (hexdecnum[p] == '6') x += 1; else if (hexdecnum[p] == '8') x += 2; else if (hexdecnum[p] == '9') x += 1; else if (hexdecnum[p] == 'a') x += 1; else if (hexdecnum[p] == 'b') x += 2; else if (hexdecnum[p] == 'd') x += 1; } cout << x << endl; return 0; }
#include <bits/stdc++.h> using namespace std; char s[10010]; 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; return 0; }
#include <bits/stdc++.h> using namespace std; int a[20] = {1, 0, 0, 0, 1, 0, 1, 0, 2, 1, 1, 2, 0, 1, 0, 0}; int main() { long long n; cin >> n; int ans = 0; if (n == 0) { cout << 1 << endl; return 0; } while (n != 0) { ans += (a[n % 16]); n /= 16; } cout << ans << endl; return 0; }
#include <bits/stdc++.h> int main() { int x, y, ans = 0; scanf("%d", &x); if (x == 0) { puts("1"); return 0; } while (x) { y = x % 16; if (y == 0 || y == 4 || y == 6 || y == 9 || y == 10 || y == 13) ans++; else if (y == 8 || y == 11) ans += 2; x /= 16; } printf("%d\n", ans); return 0; }
#include <bits/stdc++.h> using namespace std; int n, s, x; int main() { scanf("%d", &n); s = 0; if (n == 0) s = 1; while (n > 0) { x = n % 16; if (x == 0 || x == 4 || x == 6 || x == 9 || x == 10 || x == 13) ++s; if (x == 8 || x == 11) s += 2; n = n / 16; } printf("%d", s); return 0; }
#include <bits/stdc++.h> using namespace std; int a[16] = {1, 0, 0, 0, 1, 0, 1, 0, 2, 1, 1, 2, 0, 1, 0, 0}; int main() { int n; cin >> n; int ans = 0; if (n == 0) ans = 1; while (n) { ans += a[n % 16]; n /= 16; } cout << ans; return 0; }
#include <bits/stdc++.h> using namespace std; char a[1000005]; int n, i, ans; int main() { cin >> n; sprintf(a, "%X", n); int len = strlen(a); for (i = 0; i < len; i++) { if (a[i] == '0' || a[i] == '4' || a[i] == '6' || a[i] == '9' || a[i] == 'A' || a[i] == 'D') ans++; else if (a[i] == '8' || a[i] == 'B') ans += 2; } cout << ans << endl; return 0; }
#include <bits/stdc++.h> using namespace std; int main() { string digits[16] = {"0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "A", "B", "C", "D", "E", "F"}; long long int dec; cin >> dec; string hex; do { hex.insert(0, digits[dec % 16]); dec /= 16; } while (dec != 0); int k = 0; for (int i = 0; i < hex.size(); i++) { if (hex[i] == '0' || hex[i] == 'A' || hex[i] == '6' || hex[i] == '9' || hex[i] == '4' || hex[i] == 'D') k++; if (hex[i] == '8' || hex[i] == 'B') k += 2; } cout << k; return 0; }
#include <bits/stdc++.h> int main(void) { unsigned x, y, result = 0; scanf("%u", &x); do { y = x & 15; x >>= 4; if (y == 0 || y == 4 || y == 6 || y == 9 || y == 10 || y == 13) { result++; } if (y == 8 || y == 11) { result += 2; } } while (x); printf("%d", result); }
#include <bits/stdc++.h> using namespace std; template <typename T> T sqr(T x) { return x * x; } inline unsigned long long bit(int num) { return 1ull << num; } int mas[] = {1, 0, 0, 0, 1, 0, 1, 0, 2, 1, 1, 2, 0, 1, 0, 0}; int main() { long long a; cin >> a; long long s = 0; if (a == 0) s = 1; while (a) { s += mas[a % 16]; a /= 16; } cout << s << endl; 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; }
#include <bits/stdc++.h> using namespace std; int main() { int c, d; string a = ""; char b; cin >> c; if (c == 0) { a = "0"; } else { while (c != 0) { d = c % 16; if (d < 10) { b = d + '0'; } else { b = d + 'A' - 10; } a = b + a; c = c / 16; } } int x; int wynik = 0; for (int i = 0; i < a.size(); i++) { x = a[i] - '0'; if (x >= 0 && x <= 9) { if (x == 4 || x == 6 || x == 9 || x == 0) { wynik++; } else if (x == 8) { wynik += 2; } } else { x = a[i] - 'A'; if (x == 0 || x == 3) { wynik++; } else if (x == 1) { wynik += 2; } } } cout << wynik << endl; }
#include <bits/stdc++.h> using namespace std; const int MAXN = 2e5 + 17; long long n, ans; int main() { cin >> n; if (!n) { cout << 1 << endl; return 0; } while (n) { int rem = n % 16; n /= 16; if (rem == 0 || rem == 4 || rem == 6 || rem == 9 || rem == 10 || rem == 13) ans++; else if (rem == 8 || rem == 11) ans += 2; else ; } cout << ans << endl; return 0; }
#include <bits/stdc++.h> using namespace std; int n, ans; int main() { scanf("%d", &n); if (n == 0) ans = 1; while (n != 0) { int p = n % 16; n /= 16; if (p == 0) ans++; else if (p == 4) ans++; else if (p == 6) ans++; else if (p == 8) ans += 2; else if (p == 9) ans++; else if (p == 10) ans++; else if (p == 11) ans += 2; else if (p == 13) ans++; } printf("%d\n", ans); return 0; }
#include <bits/stdc++.h> int n, cir[] = {1, 0, 0, 0, 1, 0, 1, 0, 2, 1, 1, 2, 0, 1, 0, 0}; int main() { scanf("%d", &n); int ans = !n; while (n) { ans += cir[n & 15]; n >>= 4; } printf("%d", ans); }