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. 解析XML文件之使用DOM解析器

    在前面的文章中.介绍了使用SAX解析器对XML文件进行解析.SAX解析器的长处就是占用内存小.这篇文章主要介绍使用DOM解析器对XML文件进行解析. DOM解析器的长处可能是理解起来比較的直观,当然, ...

  2. [React] Implement a Higher Order Component with Render Props

    When making a reusable component, you'll find that people often like to have the API they're most fa ...

  3. UVa 112 树求和

    题意:给定一个数字,以及一个描写叙述树的字符序列,问存不存在一条从根到某叶子结点的路径使得其和等于那个数. 难点在于怎样处理字符序列.由于字符间可能有空格.换行等. 思路:本来想着用scanf的(后发 ...

  4. Codeforces Educational Codeforces Round 8 A. Tennis Tournament

    大致题意: 网球比赛,n个參赛者,每场比赛每位选手b瓶水+裁判1瓶水,所有比赛每一个參赛者p条毛巾 每一轮比赛有2^k个人參加比赛(k为2^k<=n中k的最大值),下一轮晋级人数是本轮每场比赛的 ...

  5. iBatis框架使用 4步曲

    iBatis是一款使用方便的数据訪问工具,也可作为数据持久层的框架.和ORM框架(如Hibernate)将数据库表直接映射为Java对象相比.iBatis是将SQL语句映射为Java对象. 相对于全自 ...

  6. 用Hexo搭建个人博客

    博客地址: http://astraylinux.com/ 文章地址: http://astraylinux.com/2015/06/02/linux-Init-Hexo/ Step 1 Instal ...

  7. linux内核计算时间差以及jiffies溢出

    jiffies是每一个时钟中断,都会加1.这就导致一个问题.不管jiffies(一般来说是unsigned long类型)多少个字节,总有溢出的时候. 更极端的时候.当期jiffies是0xfffff ...

  8. How to test Heat (by quqi99)

    作者:张华  发表于:2015-12-19版权声明:能够随意转载.转载时请务必以超链接形式标明文章原始出处和作者信息及本版权声明 (http://blog.csdn.net/quqi99 ) Heat ...

  9. iRedMail邮件系统配置简易视频安装教程

    iRedMail邮件系统配置简易视频安装教程        iRedMail邮件系统配置简易视频安装教程 iRedMail中文名为“艾瑞得邮件系统”, 属于开源的企业邮件解决方案,但其性能不逊于任何商 ...

  10. css3 边框阴影效果

    <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...