解题思路:类比求出10进制数各个位上的数字之和,求出12进制和16进制上的数。

 #include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
int n; int getShi(int t)
{
int ans = ;
t = n;
while(t)
{
ans += t%; //草稿纸上演示一下就知道原理。
t /= ;
}
//printf("ans10 = %d\n", ans); //打印出来,确认一下。
return ans;
} int getShiliu(int t)
{
int ans = ;
t = n;
while(t)
{
ans += t%;
t /= ;
}
//printf("ans16 = %d\n", ans);
return ans;
} int getShier(int t)
{
int ans = ;
t = n;
while(t)
{
ans += t%;
t /= ;
}
//printf("ans12 = %d\n", ans);
return ans;
} int main()
{
int a, b, c;
while(~scanf("%d", &n) && n)
{
a = getShi(n), b = getShiliu(n), c = getShier(n);
if(a == b && b == c) //刚开始,直接用a==b==c判断,是不对的,原因自己思考。
printf("%d is a Sky Number.\n", n);
else printf("%d is not a Sky Number.\n", n);
}
return ;
}

HDU Sky数 2097的更多相关文章

  1. Sky数 2097

    Problem Description Sky从小喜欢奇特的东西,而且天生对数字特别敏感,一次偶然的机会,他发现了一个有趣的四位数2992,这个数,它的十进制数表示,其四位数字之和为2+9+9+2=2 ...

  2. HDU Sky数 2079 简单易懂的代码

    题目 http://acm.hdu.edu.cn/showproblem.php?pid=2097 思路 既然要求和 十进制数字各个位数上的和是相同的, 那么16,12进制转换完之后也是10进制表示的 ...

  3. HDU 2097 Sky数

    http://acm.hdu.edu.cn/showproblem.php?pid=2097 Problem Description Sky从小喜欢奇特的东西,而且天生对数字特别敏感,一次偶然的机会, ...

  4. HDOJ(HDU) 2097 Sky数(进制)

    Problem Description Sky从小喜欢奇特的东西,而且天生对数字特别敏感,一次偶然的机会,他发现了一个有趣的四位数2992,这个数,它的十进制数表示,其四位数字之和为2+9+9+2=2 ...

  5. hdu 2097 sky数(进制转换)

    Sky数 Time Limit: 1000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submis ...

  6. HDU 2097 sky数 (进制转化)

    传送门: Sky数 Time Limit: 1000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total S ...

  7. hdoj 2097 Sky数

    Sky数 Time Limit: 1000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submis ...

  8. 杭电 2097 sky数

    Sky数 Time Limit: 1000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submis ...

  9. Hdu2097 Sky数

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2097 Problem Description Sky从小喜欢奇特的东西,而且天生对数字特别敏感,一次偶 ...

随机推荐

  1. $("#id a") - $("#id .c a") = ?

    前沿 这是之前淘宝的一道面试题,题目借用了 jQuery 选择器的语法.大概的意思是,从 #id 元素内选出所有不是 .c 后代的 a 元素,即父元素 #id 内的所有后代元素中,选出不是 .c 后代 ...

  2. struct 理解 (需要经常理解)

    2014.3.11 分析offviewer时,有一些问题,很基础的,但是忘记了,发现问题那就快点搞定它 以下内容参考自百度百科: (2)struct 结构体有点忘记了,要复习一下  定义一个结构的一般 ...

  3. UVA 11361 - Investigating Div-Sum Property 数位DP

    An integer is divisible by 3 if the sum of its digits is also divisible by 3. For example, 3702 is d ...

  4. POJ2402/UVA 12050 Palindrome Numbers 数学思维

    A palindrome is a word, number, or phrase that reads the same forwards as backwards. For example,the ...

  5. mysql之select(一)

    select 初始准备工作: 1.建木瓜库并选中 create database mugua; use mugua; 2.创建商品表.栏目表.品牌表 create table goods ( good ...

  6. Windows 代码实现关机(直接黑屏)

    整理资料的时候发现的以前的代码,本机Win7 x64 Sp1 运行直接关机,黑屏.就是利用RtlAdjustPrivilege函数提权,代码中的注释写的很详细了.用的VS2010写的,直接编译成x64 ...

  7. Android Non-UI to UI Thread Communications(Part 1 of 5)

    original:http://www.intertech.com/Blog/android-non-ui-to-ui-thread-communications-part-1-of-5/ ANDRO ...

  8. ks全自动安装centos

    1. 全新安装centos,选择好所需定制包 2. 完成安装后会在root下面生成一个install.log(rpm包列表)anaconda-ks.cfg(下文的ks.cfg基于此文件修改) 3. 将 ...

  9. 使用内网的Docker Image启动AcmeAir应用

    1.修改docker启动选项,添加信赖私有仓库 为了拉取docker.oneapm.me仓库里的镜像,我们需要将它添加为信赖仓库,方式是在启动选项中添加 --insecure-registry doc ...

  10. Hibernate笔记——C3P0配置

    Hibernate作为持久层(ORM)框架,操作数据库,自然也就离不开数据库连接池了.其支持多种连接池,这里就用最熟悉的C3P0连接池. C3P0连接池前面已经介绍了并使用很多次了就不再详细说明了. ...