Specialized Four-Digit Numbers


Time Limit: 2 Seconds      Memory Limit: 65536 KB


Find and list all four-digit numbers in decimal notation that have the property that the sum of its four digits equals the sum of its digits when represented in hexadecimal (base 16)
notation and also equals the sum of its digits when represented in duodecimal (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

There is no input for this problem.

Output

Your output is to be 2992 and all larger four-digit numbers that satisfy the requirements (in strictly increasing order), each on a separate line with no leading or trailing blanks, ending
with a new-line character. There are to be no blank lines in the 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


Source: Pacific Northwest 2004





————————————————————————————————————
题目的意思是找出所有4位整数,要求他的10进制,12进制,16进制各位和相等


思路:暴力枚举


#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <queue>
#include <set>
#include <stack>
#include <map>
#include <functional>
#include <bitset>
#include <string> using namespace std; #define LL long long
#define INF 0x3f3f3f3f int main()
{
for(int i=1000;i<10000;i++)
{
int x1=i;
int ans1=0;
while(x1)
{
ans1+=x1%10;
x1/=10;
}
int x2=i;
int ans2=0;
while(x2)
{
ans2+=x2%12;
x2/=12;
}
int x3=i;
int ans3=0;
while(x3)
{
ans3+=x3%16;
x3/=16;
}
if(ans1==ans2&&ans1==ans3)
printf("%d\n",i); }
return 0;
}

ZOJ2405 Specialized Four-Digit Numbers 2017-04-18 20:43 44人阅读 评论(0) 收藏的更多相关文章

  1. Self Numbers 分类: POJ 2015-06-12 20:07 14人阅读 评论(0) 收藏

    Self Numbers Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 22101   Accepted: 12429 De ...

  2. Hdu1547 Bubble Shooter 2017-01-20 18:38 44人阅读 评论(0) 收藏

    Bubble Shooter Time Limit : 2000/1000ms (Java/Other)   Memory Limit : 65536/32768K (Java/Other) Tota ...

  3. c++map的用法 分类: POJ 2015-06-19 18:36 11人阅读 评论(0) 收藏

    c++map的用法 分类: 资料 2012-11-14 21:26 10573人阅读 评论(0) 收藏 举报 最全的c++map的用法 此文是复制来的0.0 1. map最基本的构造函数: map&l ...

  4. 移植QT到ZedBoard(制作运行库镜像) 交叉编译 分类: ubuntu shell ZedBoard OpenCV 2014-11-08 18:49 219人阅读 评论(0) 收藏

    制作运行库 由于ubuntu的Qt运行库在/usr/local/Trolltech/Qt-4.7.3/下,由makefile可以看到引用运行库是 INCPATH = -I/usr//mkspecs/d ...

  5. iOS开发之监听键盘高度的变化 分类: ios技术 2015-04-21 12:04 233人阅读 评论(0) 收藏

    最近做的项目中,有一个类似微博中的评论转发功能,屏幕底端有一个输入框用textView来做,当textView成为第一响应者的时候它的Y值随着键盘高度的改变而改变,保证textView紧贴着键盘,但又 ...

  6. HDU1349 Minimum Inversion Number 2016-09-15 13:04 75人阅读 评论(0) 收藏

    B - Minimum Inversion Number Time Limit:1000MS     Memory Limit:32768KB     64bit IO Format:%I64d &a ...

  7. Doubles 分类: POJ 2015-06-12 18:24 11人阅读 评论(0) 收藏

    Doubles Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 19954   Accepted: 11536 Descrip ...

  8. HDU6023 Automatic Judge 2017-05-07 18:30 73人阅读 评论(0) 收藏

    Automatic Judge Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 131072/131072 K (Java/Others ...

  9. 全面解析sizeof(上) 分类: C/C++ StudyNotes 2015-06-15 10:18 188人阅读 评论(0) 收藏

    以下代码使用平台是Windows7 64bits+VS2012. sizeof是C/C++中的一个操作符(operator),其作用就是返回一个对象或者类型所占的内存字节数,使用频繁,有必须对齐有个全 ...

随机推荐

  1. 迷你MVVM框架 avalonjs 学习教程13、模板引用

    稍为复杂一点的网站都是多个前端工程师合作而成,因此分工是必需的.简单一点的分工就是一个人负责一个频道,某个页面是由一个人全部做的:但如果涉及到一个页面非常复杂,需要多个人同时动工呢?于是到模板的出场时 ...

  2. 批量导入数据(Mysql)报MySQL server has gone away 问题的解决方法

    问题分析 首先度娘:mysql出现ERROR : (2006, 'MySQL server has gone away') 的问题意思就是指client和MySQL server之间的链接断开了. 造 ...

  3. EXCEL保存提示“隐私问题警告:此文档中包含宏……”解决办法

    先点击“禁止宏运行”的那个按钮.打开文件后,按alt + F11 进入宏编辑器,在“工程”里查看是什么宏.如果是你需要的,就留着.否则右击这个宏名称,选择“移除”. 另外,如果是你需要的,还需要在 工 ...

  4. go递归函数如何传递数组切片slice

    数组切片slice这个东西看起来很美好,真正用起来会发现有诸多的不爽. 第一,数组.数组切片混淆不清,使用方式完全一样,有时候一些特性又完全不一样,搞不清原理很容易误使用. 第二,数组切片的appen ...

  5. Managing Images on smartos

    SmartOS依赖images.images是包含在创建新zone或虚拟机时使用的磁盘或文件系统映像和元数据的模板. images使用imgadm工具进行管理. 使用此工具,您可以: 查看和下载在公共 ...

  6. oracle存储过程-获取错误信息

    dbms_output.put_line('code:' || sqlcode); dbms_output.put_line('errm:' || sqlerrm); dbms_output.put_ ...

  7. np.hsplit()

    numpy.hsplit numpy.hsplit(ary, indices_or_sections)[source] Split an array into multiple sub-arrays ...

  8. inputStream、File、Byte、String等等之间的相互转换

    一:inputStream转换 1.inputStream转为byte //方法一 org.apache.commons.io.IOUtils包下的实现(建议) IOUtils.toByteArray ...

  9. collections之命名元组

    #python中没有为我们提供可命名的tuple的类,这个类需要我们自己来定义,下面我们就自己来定义一个类,然后namedtuple就是可以通过名称来get#tuple中的元素,python中的tup ...

  10. 无法打开登录所请求的数据库 "****"。登录失败

    错误:无法打开登录所请求的数据库 "****".登录失败.用户 '****' 登录失败. sql2005连接时出现的错误 解决方法:权限不够,给登录名授权,赋予管理员角色,在登录名 ...