[恢]hdu 2097
2011-12-14 05:33:58
地址:http://acm.hdu.edu.cn/showproblem.php?pid=2097
题意:中文,进制转换。
代码:
# include <stdio.h>
int base(int n, int b)
{
int sum = 0 ;
while (n)
{
sum += n%b ;
n /= b ;
}
return sum ;
}
int main ()
{
int n ;
while (~scanf ("%d", &n) && n)
{
if (base(n,10) == base(n,12) && base(n,10) == base(n,16))
printf ("%d is a Sky Number.\n", n) ;
else
printf ("%d is not a Sky Number.\n", n) ;
}
return 0 ;
}