Specialized Four-Digit Numbers

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 7358    Accepted Submission(s): 5415

Problem Description
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
1893(12), 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
水题,问一个四位数的十进制和十二进制和十六进制个各位数之和是否相等
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cstdio>
#include <vector>
#include <queue>
#include <cstdlib>
#include <iomanip>
#include <cmath>
#include <ctime>
#include <map>
#include <set>
using namespace std;
#define lowbit(x) (x&(-x))
#define max(x,y) (x>y?x:y)
#define min(x,y) (x<y?x:y)
#define MAX 100000000000000000
#define MOD 1000000007
#define pi acos(-1.0)
#define ei exp(1)
#define PI 3.141592653589793238462
#define INF 0x3f3f3f3f3f
#define mem(a) (memset(a,0,sizeof(a)))
typedef long long ll;
int main()
{
for(int i=;i<=;i++)
{
int n=i;
int k=i;
int m=i;
int ans=,pos=,cnt=;
while(n)
{
ans+=n%;
n/=;
}
while(m>=)
{
cnt+=m%;
m/=;
}
cnt+=m;
while(k>=)
{
pos+=k%;
k/=;
}
pos+=k;
if(pos==ans && ans==cnt) printf("%d\n",i);
}
return ;
}

HDU 1197 Specialized Four-Digit Numbers的更多相关文章

  1. HDU 1197 Specialized Four-Digit Numbers (枚举+进制转化,简单)

    题意:让求从2992-9999中所有数字,满足10进制各位之和和12进制和16进制各位数字之和相等. 析:没啥可说的,只能枚举从2992-9999,每个进制都算一下. 代码如下: #include & ...

  2. HDOJ 1197 Specialized Four-Digit Numbers

    Problem Description Find and list all four-digit numbers in decimal notation that have the property ...

  3. 【HDOJ】1197 Specialized Four-Digit Numbers

    水题,暴力可解. #include <iostream> using namespace std; int chg(int n, int base); int main() { int i ...

  4. HDU 6659 Acesrc and Good Numbers (数学 思维)

    2019 杭电多校 8 1003 题目链接:HDU 6659 比赛链接:2019 Multi-University Training Contest 8 Problem Description Ace ...

  5. HDU 2817 A sequence of numbers

    http://acm.hdu.edu.cn/showproblem.php?pid=2817 __int64 pow_mod (__int64 a, __int64 n, __int64 m)快速幂取 ...

  6. hdu 5676 ztr loves lucky numbers

    题目链接:hdu 5676 一开始看题还以为和数位dp相关的,后来才发现是搜索题,我手算了下,所有的super lucky number(也就是只含数字4, 7且4, 7的数量相等的数)加起来也不过几 ...

  7. HDU 2817 A sequence of numbers 整数快速幂

    A sequence of numbers Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Ot ...

  8. HDU 5676 ztr loves lucky numbers (模拟)

    ztr loves lucky numbers 题目链接: http://acm.hust.edu.cn/vjudge/contest/121332#problem/I Description ztr ...

  9. HDOJ(HDU) 2138 How many prime numbers(素数-快速筛选没用上、)

    Problem Description Give you a lot of positive integers, just to find out how many prime numbers the ...

随机推荐

  1. python的开发工具UliPad安装篇

    之前文章里写过一个搭建windows下搭建Selenium+Eclipse+Python环境,如今认为这个Eclipse太大了,太笨重了,重新启动又慢,像Python脚本轻级语言,不是必需用那么大的工 ...

  2. VS链接数据库

    可以用VS链接数据库,并进行数据库操作.前提是安装了Sqlserver,活着连接线上的数据库服务器.

  3. Conservative GC (Part one)

    目录 保守式GC 不明确的根 指针和非指针的区别 貌似指针的非指针 不明确数据结构 优点 准确式GC 正确的根 打标签 不把寄存器和栈等当做根 优点 缺点 间接引用 经由句柄引用对象 优缺点 保守式G ...

  4. 【Python】【Head First Python】【chapter1】1 - 导入模块

    导入模块 导入模块有三种方法,以导入sys模块为例: 第一是import module 形式导入 import sys location = sys.stdout 第二是from module imp ...

  5. ios程序启动过程和UIWidnow介绍

    一.iOS程序的完整启动过程(有storyboard) 1.先执行main函数,main内部会调用UIApplicationMain函数 2.UIApplicationMain函数里面做了什么事情: ...

  6. Mysql学习总结(3)——MySql语句大全:创建、授权、查询、修改等

    一.用户创建.权限.删除 1.连接MySql操作 连接:mysql -h 主机地址 -u 用户名 -p 用户密码 (注:u与root可以不用加空格,其它也一样) 断开:exit (回车) 打开cmd, ...

  7. HRBUST 1376 能量项链

    能量项链 Time Limit: 1000ms Memory Limit: 32768KB This problem will be judged on HRBUST. Original ID: 13 ...

  8. ecshop微信通中微信自动登录的设置方法

    ecshop微信通中微信自动登录的设置方法 来 源:共享世纪 作 者:网络 时间:2015-12-03 点击: 4017 注意:微信自动登录,必须同时满足两个条件: 第一.微信公众号必须是服务号经过认 ...

  9. 游戏server之server优化思路

    本文仅仅是提供一些游戏server优化思路,当中一些思路是用在不同场合的,不是同个架构的.须要依据应用场景选用合适方式. 本文的引用的文章都是在自己写的在本博客内的.也都是上线开几百个服的成熟项目的. ...

  10. 解决切换场景时NGUI图集资源未释放的问题

    使用unity3d编辑器,在切换场景的时候.NGUI的图集没有释放造成内存不足游戏闪退的问题. 默认情况下,unity3d切换场景之后会释放不用的内存,即内部会调用Resources.UnloadUn ...