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

G - Specialized Four-Digit Numbers(1.5.2)的更多相关文章

  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. 【Kickstart】2017 Round (Practice ~ G)

    Practice Round Problem A Country Leader (4pt/7pt) Problem B Vote (5pt/8pt) Problem C Sherlock and Pa ...

  6. PAT/进制转换习题集

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

  7. js判断小数点几位

    js如何判断小数点后有几位 <script> var n=3.143423423;alert(n.toString().split(".")[1].length); & ...

  8. 数据结构——POJ 1686 Lazy Math Instructor 栈的应用

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

  9. Inside a low budget consumer hardware espionage implant

    The following analysis was performed on a S8 data line locator which replied to the hidden SMS comma ...

随机推荐

  1. 使用Jquery与vuejs操作dom比较

    jquery实现添加功能 <!DOCTYPE html> <html> <head> <meta charset="UTF-8"> ...

  2. 十分钟了解socket

    socket通讯方式------socket是TCP/IP协议的网络数据通讯接口(一种底层的通讯的方式).socket是IP地址和端口号的组合.例如:192.168.1.100:8080 原理就是TC ...

  3. 深入浅出理解Javascript原型概念以及继承机制(转)

    在Javascript语言中,原型是一个经常被讨论到但是有非常让初学者不解的概念.那么,到底该怎么去给原型定义呢?不急,在了解是什么之前,我们不妨先来看下为什么. Javascript最开始是网景公司 ...

  4. 深度学习:Sigmoid函数与损失函数求导

    1.sigmoid函数 ​ sigmoid函数,也就是s型曲线函数,如下: 函数: 导数: ​ 上面是我们常见的形式,虽然知道这样的形式,也知道计算流程,不够感觉并不太直观,下面来分析一下. 1.1 ...

  5. javascript学习笔记 - 引用类型 基本包装类型

    六 基本包装类型 Boolean,Number,String 这三个引用类型亦称为基本包装类型,与基本的数据类型boolean,number,string相关联.为了方便操作这些基本类型的数据. 引用 ...

  6. Mysql书签

    关于 MySQL UTF8 编码下生僻字符插入失败/假死问题的分析

  7. iOS--app自定义相册--创建相簿,存储图片到手机

    我们在APP中点击照片,都会显示出大图,然后在大图的上面会有个保存照片的按钮,照片直接保存到了系统的相册中,但是因为公司产品的需要,让你创建和APP同名的相册保存在里面,那么就对了,可以看下具体的代码 ...

  8. 一步一步,完成sparkMLlib对日志文件的处理(1)

    https://blog.csdn.net/u012834750/article/details/81014997    初学第一天,当然是完成helloWorld啦,有点艰难,2个小时,在idea, ...

  9. [cogs729]圆桌问题(最大流)

    传送门 模型 二分图多重匹配问题,可以用最大流解决. 实现 建立二分图,每个单位为X集合中的顶点,每个餐桌为Y集合中的顶点,增设附加源S和汇T. 1.从S向每个Xi顶点连接一条容量为该单位人数的有向边 ...

  10. java中文乱码问题解决

    1 处理乱码方式: 1 连接数据库的时候 jdbc.properties:jdbc:mysql://localhost:3306/myproject?useUnicode=true&chara ...