10019 - Funny Encryption Method
Solution Description : Simple base conversion problem Input int n convert is to binary // You can free generate 0 to 9999 count one for binary count the number of one in binary You can use a array from 0 to 9 for hexadecimal value count HexOne[] = {0,1,1,2,1,2,2,3,1,2} If n = 256 for 2 hexOne[2]=1 5 hexOne[5]=2 6 hexOne[6]=2 So total one for hexadecimal is (1+2+2) Print total one for binary and total one for hexadecimal |
||||||||||