Title description
The meaning of the question: Find the number of such four-digit numbers, and satisfy that the sum of the numbers is equal when expressed in decimal, decimal binary, and hexadecimal.
The question is relatively simple, water question, only need to write a function of conversion
#include<cstdio>
using namespace std;
int Calc(int base,int n){
int sum=0;
while(n!=0){
sum+=n%base;
n/=base;
}
return sum;
}
int main(){
for(int i=2992;i<=9999;i++)
{
int num=Calc(10,i);
if(num==Calc(12,i)&&num==Calc(16,i))
printf("%d\n",i);
}
return 0;
}