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 <stdio.h>

 int sum(int number,int p);

 int main(){
int a;
int b;
int c;
int i; for(i=;i<=;i++){
a=sum(i,);
b=sum(i,);
c=sum(i,); if(a==b && b==c)
printf("%d\n",i);
} return ;
} int sum(int number,int p){
int result; result=;
while(number){
result+=number%p;
number/=p;
} return result;
}

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

  1. [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 ...

  2. 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 ...

  3. 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'}.  ...

  4. [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 ...

  5. 利用Python【Orange】结合DNA序列进行人种预测

    http://blog.csdn.net/jj12345jj198999/article/details/8951120 coursera上 web intelligence and big data ...

  6. PAT/进制转换习题集

    B1022. D进制的A+B (20) Description: 输入两个非负10进制整数A和B(<=230-1),输出A+B的D (1 < D <= 10)进制数. Input: ...

  7. [转]http://lua-users.org/wiki/LpegTutorial

    Simple Matching LPeg is a powerful notation for matching text data, which is more capable than Lua s ...

  8. FZU 2215 Simple Polynomial Problem(简单多项式问题)

    Description 题目描述 You are given an polynomial of x consisting of only addition marks, multiplication ...

  9. Problem K 栈

    Description A math instructor is too lazy to grade a question in the exam papers in which students a ...

  10. PAT 1019

    1019. General Palindromic Number (20) A number that will be the same when it is written forwards or ...

随机推荐

  1. How to setup Wicket Examples in Eclipse

    Wicket examples is a good place to learn Apache Wicket by examples, and a must reference site for ne ...

  2. Java沙箱技术

    自从Java技术出现以来,有关Java平台的安全性及由Java技术发展所引发的新的安全性问题,引起了越来越多的关注.目前,Java已经大量应用在各个领域,研究Java的安全 性对于更好地使用Java具 ...

  3. poj 3216 Repairing Company(最短路Floyd + 最小路径覆盖 + 构图)

    http://poj.org/problem?id=3216 Repairing Company Time Limit: 1000MS   Memory Limit: 131072K Total Su ...

  4. 10 个你需要了解的最佳 javascript 开发实践

    原文:Top 10 “Must Follow” JavaScript Best Practices Javascript 的很多扩展的特性是的它变得更加的犀利, 同时也给予程序员机会创建更漂亮并且更让 ...

  5. C#调用C++编写的dll库

    我用vs2008建的C++ dll类库,名字test_interopVC,和C#的CeshiVC项目 一:C++项目dll类库: 1.test_interopVC.h,主要简单的测试,所以就在一个类里 ...

  6. 多线程下载网络歌曲&播放歌曲&并用seekbar调节进度&显示歌曲两边的时间

    这里先给一个处理时间格式的代码: /** * 时间的处理 *  * @param time * @return */ public static String getTimeFromInt(int t ...

  7. linux tail命令的使用方法详解 (转载)

    本文介绍Linux下tail命令的使用方法.linux tail命令用途是依照要求将指定的文件的最后部分输出到标准设备,通常是终端,通俗讲来,就是把某个档案文件的最后几行显示到终端上,假设该档案有更新 ...

  8. CMSIS Example - osTimer osTimerCreate osTimerStart

    osTimerId timer; uint32_t cnt=; void timerHandler( void * arg ) { cnt++; osTimerStart( timer, ); } o ...

  9. intval()和(int)转换使用与区别

    <?php echo "<br/>数值强制转换:"; $string="2a"; $string1=intval($string); echo ...

  10. Asp.Net BulletedList

    BulletedList使用及详解 BulletedList是一个让你轻松在页面上显示项目符号和编号格式(Bulledted List)的控件.对于ASP.NET 1.x里要动态显示Bulledted ...