Specialized Four-Digit Numbers
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.)
#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的更多相关文章
- [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 ...
- 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 ...
- 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'}. ...
- [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 ...
- 利用Python【Orange】结合DNA序列进行人种预测
http://blog.csdn.net/jj12345jj198999/article/details/8951120 coursera上 web intelligence and big data ...
- PAT/进制转换习题集
B1022. D进制的A+B (20) Description: 输入两个非负10进制整数A和B(<=230-1),输出A+B的D (1 < D <= 10)进制数. Input: ...
- [转]http://lua-users.org/wiki/LpegTutorial
Simple Matching LPeg is a powerful notation for matching text data, which is more capable than Lua s ...
- FZU 2215 Simple Polynomial Problem(简单多项式问题)
Description 题目描述 You are given an polynomial of x consisting of only addition marks, multiplication ...
- Problem K 栈
Description A math instructor is too lazy to grade a question in the exam papers in which students a ...
- PAT 1019
1019. General Palindromic Number (20) A number that will be the same when it is written forwards or ...
随机推荐
- Oracle用户的单张表的读写权限控制
在oracle数据库的用户下,一张表需要做读写控制,只能读和写,不能删除和修改.开发人员开始想从用户权限上去实现. 经过一番讨论,判读从权限上去实现该需求是不合适的. 这个用户下很多表,根本不会被一个 ...
- Mongo数据模型
Mongo数据模型 一个Mongo系统(参考上述部署)包含一组数据库 一个 database 包含一组collection 一个 collection 包含一组document 一个 document ...
- (剑指Offer)面试题33:把数组排成最小的数
题目: 输入一个正整数数组,把数组里所有数字拼接起来排成一个数,打印能拼接出的所有数字中最小的一个.例如输入数组{3,32,321},则打印出这三个数字能排成的最小数字为321323. 思路: 1.全 ...
- thinkphp 3+ 观后详解 (1)
最近面试了一些公司,发现自己的对于架构能力的不足,于是决定开始从最基本的代码做起.先看看大牛们怎么架构整个框架的.鉴于国外的框架比较难懂,于是就选择了国内比较流行的thinkphp来进行研究. 下面写 ...
- NHibernate分页
转载:http://www.cnblogs.com/tenghoo/archive/2011/02/14/1954393.html NHibernate专题:http://kb.cnblogs.com ...
- cocos2dx 手势识别
转自:http://blog.csdn.net/qq634416025/article/details/8685187 g_rGemertricRecognizer = new GeometricRe ...
- Visual Studio 2015 和 Apache Cordova
英文原版:http://www.codeproject.com/Articles/860150/Visual-Studio-and-Apache-Cordova 在开始前,问一下自己下面这些问题: 熟 ...
- hdu 5591 ZYB's Game 博弈论
ZYB's Game Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://acm.hdu.edu.cn/showproblem.php?pid=55 ...
- XianBicycle
https://github.com/xialinchong/secrettalkandroid https://github.com/talentprince/PhotoView https://g ...
- 一个简单的弹出层ProgressBar
https://github.com/eltld/SimpleLoading