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 ...
随机推荐
- 转】Spark DataFrames入门指南:创建和操作DataFrame
原博文出自于: http://blog.csdn.net/lw_ghy/article/details/51480358 感谢! 一.从csv文件创建DataFrame 本文将介绍如何从csv文件创建 ...
- POJ 1269 Intersecting Lines(直线相交判断,求交点)
Intersecting Lines Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 8342 Accepted: 378 ...
- ubuntu14.04恢复系统默认中文字体
今天 Ubuntu14.04已发布就进行了更新,在配置过程中,无意安装了某些中文字体,导致系统的中文字体极其难看,根据网上说的修改配置文件和tweak 修改的方法都不能解决,最终找到的解决办法(htt ...
- jsp 是什么 ,jsp 隐式对象
google 搜索 java server page http://www.oracle.com/technetwork/java/javaee/jsp/index.html http://docs. ...
- Windows消息机制要点
1. 窗口过程 每个窗口会有一个称为窗口过程的回调函数(WndProc),它带有四个参数,分别为:窗口句柄(Window Handle),消息ID(Message ID),和两个消息参数(wP ...
- Java 线程池学习
Java里面线程池的顶级接口是Executor,但是严格意义上讲Executor并不是一个线程池,而只是一个执行线程的工具.真正的线程池接口是ExecutorService. 下面这张图完整描述了线程 ...
- Rank() over(partition ... 分组统计的实例
USE [NanFeng]GO/****** Object: StoredProcedure [dbo].[st_MES_RptMaterilSum] Script Date: 04/18/2016 ...
- AS:加载新版本的SWF文件。
方案一: 文件名+版本号,区别对待不同的版本控制,有设定值后会加上_v_x的后缀名.如:加载主文件 main.swf, 被命名为:Main_v_60.swf . 方案二: loader.load(ne ...
- SetWindowsHookEx 相关
SetWindowsHookEx function https://msdn.microsoft.com/en-us/library/windows/desktop/ms644990(v=vs.85) ...
- Flexigrid在IE下不显示数据的处理
文章总结自我的论坛提问: http://bbs.csdn.net/topics/390498434?page=1#post-394918028 解决方法: 网上的答案经我验证都是不靠谱的,以后大家就知 ...