Question:
A number is decomposed into quality factors and multiplied. The sum of each bit of the original number is equal to the sum of all the decomposed numbers.
This is the decomposition factor + enumeration. Note that prime numbers cannot be calculated.
# Include <stdio. h> typedef long ll; void bitsum (ll n, ll * s) {int t; while (n) {T = n % 10; N/= 10; * s + = T ;}} int main () {ll num, ANS, TMP; ll sum1, sum2; bool flag; // flag is used to mark whether a number is a prime number. While (scanf ("% LLD", & num), num) {If (num = 1) num = 2; while (Num ++) {sum2 = sum1 = 0; TMP = num; ans = num; flag = 0; bitsum (TMP, & sum1); While (TMP & 1) = 0) {TMP >>= 1; sum2 + = 2; flag = 1;} For (ll I = 3; I * I <= TMP; I + = 2) {While (TMP % I = 0) {tmp/= I; bitsum (I, & sum2); flag = 1 ;}} if (TMP> 1) bitsum (TMP, & sum2); If (sum1 = sum2 & flag) {printf ("% LLD \ n", ANS); break ;}}}}