水题
code:
<span style="font-size:18px;">#include <iostream>
using namespace std;
int sum(int a, int b)
{
int ret=0;
while (a)
{
ret += a%b;
a /= b;
}
return ret;
}
bool judge(int n)
{
if (sum(n, 10) == sum(n, 12) && sum(n,10) == sum(n, 16))
return true;
else
return false;
}
int main()
{
for (int i = 2992; i <= 9999; i++)
{
if (judge(i))
cout << i << endl;
}
//system("pause");
return 0;
}
</span>