題目:
https://onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=12&page=show_problem&problem=960
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
| #include <iostream> #include <vector> #include <bitset> #include <algorithm>
using namespace std;
int main(){ int n; cin >> n >> ws; while(n--){ int num; cin >> num; bitset<16> b1(num); string s = to_string(num); int hexValue = stoi(s, nullptr, 16); bitset<16> b2(hexValue); cout << b1.count() << ' ' << b2.count() << '\n'; } return 0; }
|