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 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
...
#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;
}

最新文章

  1. 温故而知新 css + html 超级牛逼的居中策略
  2. ActiveReports 9实战教程(3): 图文并茂的报表形式
  3. hdu 4389 X mod f(x) 数位DP
  4. 预告:准备开个坑,集中学习一下esp32模块
  5. STL——迭代器的概念
  6. The Suspects
  7. Js 导出Excel IE ActiveX控件
  8. [置顶] vs2008 编译adb 支持4.2 android 系统(增加push 命令的进度)
  9. jquery ColorPicker 颜色选择器
  10. (转)ORACLE中SID和SERVICE_NAME的区别
  11. QT的radioButton组的使用
  12. Cesium几个案例介绍
  13. mac上安装iterm2的一些步骤记录
  14. 第二章 python的介绍及变量
  15. html常用标签整理
  16. js分号的重要性
  17. R语言常用包分类总结
  18. sqlserver的资源调控器
  19. [UOJ213][UNR #1]争夺圣杯
  20. java 自定义泛型

热门文章

  1. 大数据学习——scala数组
  2. python基础补漏-07-正则表达式
  3. 【LeetCode】Remove Duplicates from Sorted Array(删除排序数组中的重复项)
  4. 聊聊、Java 网络编程
  5. hdu6074[并查集+LCA+思维] 2017多校4
  6. 【Luogu】P3317重建(高斯消元+矩阵树定理)
  7. Jdbc执行存储过程报数据库事务无法执行的异常
  8. django前端渲染多对多关系(比如一本书的作者有哪些)
  9. stein法求gcd 学习笔记
  10. poj 3168 Barn Expansion