题解 | #小q的数列#
小q的数列
https://www.nowcoder.com/practice/76796815518f4db5b800775581cda1e4
#include<stdio.h> int main() { long long t, n, i; scanf("%lld", &t); long long sum = 0; long long num = 0; while(t--) { sum = 0; num = 0; scanf("%lld", &n); while(n) { if(n%2==1) { sum++; } n = n>>1; } for(i=0; i<sum; i++) { num = num*2+1; } printf("%lld %lld\n", sum, num); } return 0; }