G - Specialized Four-Digit Numbers(1.5.2)
Time Limit:1000MS Memory Limit:65536KB 64bit IO Format:%I64d
& %I64u
cid=1006#status//G/0" class="ui-button ui-widget ui-state-default ui-corner-all ui-button-text-only" style="font-family:Verdana,Arial,sans-serif; font-size:1em; border:1px solid rgb(211,211,211); background-color:rgb(227,228,248); color:rgb(85,85,85); display:inline-block; position:relative; padding:0px; margin-right:0.1em; zoom:1; overflow:visible; text-decoration:none">Status
Description
(base 12) notation.
For example, the number 2991 has the sum of (decimal) digits 2+9+9+1 = 21. Since 2991 = 1*1728 + 8*144 + 9*12 + 3, its duodecimal representation is 189312, and these digits also sum up to 21. But in hexadecimal 2991 is BAF16, and 11+10+15
= 36, so 2991 should be rejected by your program.
The next number (2992), however, has digits that sum to 22 in all three representations (including BB016), so 2992 should be on the listed output. (We don't want decimal numbers with fewer than four digits -- excluding leading zeroes -- so that 2992
is the first correct answer.)
Input
Output
The first few lines of the output are shown below.
Sample Input
There is no input for this problem
Sample Output
2992
2993
2994
2995
2996
2997
2998
2999
...
#include <iostream>
#include<cmath>
#include<iomanip>
using namespace std;
int x,y;
int sa(int i)
{
y=0;
while(i!=0)
{ y+=i%10;
i=i/10;
}
return y;
}
int sb(int i)
{
y=0;
while(i!=0)
{ y+=i%12;
i=i/12;
}
return y;
}
int sc(int i)
{
y=0;
while(i!=0)
{ y+=i%16;
i=i/16;
}
return y;
}
int main()
{
int a,b,c,n,i,d; for(i=2992;i<10000;i++)
{
a=sa(i);
b=sb(i);
c=sc(i);
if(a==b&&b==c)
printf("%d\n",i);
} return 0;
}
G - Specialized Four-Digit Numbers(1.5.2)的更多相关文章
- [Swift]LeetCode902. 最大为 N 的数字组合 | Numbers At Most N Given Digit Set
We have a sorted set of digits D, a non-empty subset of {'1','2','3','4','5','6','7','8','9'}. (Not ...
- 902. Numbers At Most N Given Digit Set
We have a sorted set of digits D, a non-empty subset of {'1','2','3','4','5','6','7','8','9'}. (Not ...
- LeetCode902. Numbers At Most N Given Digit Set
题目: We have a sorted set of digits D, a non-empty subset of {'1','2','3','4','5','6','7','8','9'}. ...
- [LeetCode] 902. Numbers At Most N Given Digit Set 最大为 N 的数字组合
We have a sorted set of digits D, a non-empty subset of {'1','2','3','4','5','6','7','8','9'}. (Not ...
- 【Kickstart】2017 Round (Practice ~ G)
Practice Round Problem A Country Leader (4pt/7pt) Problem B Vote (5pt/8pt) Problem C Sherlock and Pa ...
- PAT/进制转换习题集
B1022. D进制的A+B (20) Description: 输入两个非负10进制整数A和B(<=230-1),输出A+B的D (1 < D <= 10)进制数. Input: ...
- js判断小数点几位
js如何判断小数点后有几位 <script> var n=3.143423423;alert(n.toString().split(".")[1].length); & ...
- 数据结构——POJ 1686 Lazy Math Instructor 栈的应用
Description A math instructor is too lazy to grade a question in the exam papers in which students a ...
- Inside a low budget consumer hardware espionage implant
The following analysis was performed on a S8 data line locator which replied to the hidden SMS comma ...
随机推荐
- seleniumIDE使用
1.selenium IDE使用:适用于火狐浏览器 2.界面按钮包括录制(右上角的红点),运行脚本(中上页的绿色三角,包括依次运行和单个运行的2个运行按钮) 3.导出文件为.java,在文件选项中
- php将数组写入到文件的三种方法
php将数组原样写入或保存到文件有三种方法可以实现, 第一种方法是使用serialize, 第二种方法是使用print_r, 第三种方法是使用var_export, 本文章向大家介绍这三种方法是如何将 ...
- pip安装超时,更换国内镜像源安装
pip安装超时问题 pip install --index 源地址 安装包 常用镜像源地址: http://pypi.douban.com/ 豆瓣 http://pypi.mirrors.ustc.e ...
- javascript学习笔记-数据类型
一 数据类型 基本类型:undefined,null,boolean,number,string 保存在栈内存中 占用空间固定 变量直接从栈内存中存取的是该值 引用类型: ...
- spl_autoload_register和__autoload
1.实例化一个未定义的类时会触发 2.类存在继承关系时,被继承的类没有引入的情况下,会触发 (继承关系的两个类必须在同一个目录下) __autoload 实例化PRINTIT类,'PRINTIT'作 ...
- Invalid regular expression flags 错误
找到写正则表达式的地方,检查是不是写了一个非法的正则表达式. Invalid regular expression flags
- [luoguP2601] [ZJOI2009]对称的正方形(二维Hash + 二分 || Manacher)
传送门 很蒙蔽,不知道怎么搞. 网上看题解有说可以哈希+二分搞,也有的人说用Manacher搞,Manacher是什么鬼?以后再学. 对于这个题,可以从矩阵4个角hash一遍,然后枚举矩阵中的点,再二 ...
- NOIP2012开车旅行 【倍增】
题目 小 A 和小 B 决定利用假期外出旅行,他们将想去的城市从 1 到 N 编号,且编号较小的城市在编号较大的城市的西边,已知各个城市的海拔高度互不相同,记城市 i 的海拔高度为Hi,城市 i 和城 ...
- 刷题总结——松鼠的新家(bzoj3631)
题目: Description 松鼠的新家是一棵树,前几天刚刚装修了新家,新家有n个房间,并且有n-1根树枝连接,每个房间都可以相互到达,且俩个房间之间的路线都是唯一的.天哪,他居然真的住在“树”上. ...
- 说说IO(一)- IO的分层
IO性能对于一个系统的影响是至关重要的.一个系统经过多项优化以后,瓶颈往往落在数据库:而数据库经过多种优化以后,瓶颈最终会落到IO.而IO性能的发展,明显落后于CPU的发展.Memchached也好, ...