ZOJ 2405 Specialized Four-Digit Numbers
http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemId=1405
要求找出4位数所有10进制、12进制、16进制他们各位数字之和相等。
#include<cstdio>
int getsum(int n,int k)
{
int sum=0;
while(n)
{
sum+=n%k;
n/=k;
} return sum;
}
int main()
{
int n=1000;
while(n<10000)
{
int sum1=getsum(n,10);
int sum2=getsum(n,12);
int sum3=getsum(n,16);
if(sum1==sum2 && sum1==sum3)
printf("%d\n",n); n++;
}
return 0;
}
ZOJ 2405 Specialized Four-Digit Numbers的更多相关文章
- ZOJ Problem Set - 1383 Binary Numbers
水题,输出的时候注意下 #include <stdio.h> #include <math.h> int main() { int d; scanf("%d" ...
- ZOJ Problem Set - 1078 Palindrom Numbers
属于水题,主要是涉及到回文问题. 这里标注下进制转换的方法: while(n) { p[i]=n%basis; n/=basis; } 见代码: #include <stdio.h> in ...
- 【思路,dp,BigInteger】ZOJ - 2598 Yet Another Digit
[redundant binary - 冗余二进制]:由0,1,2构成的二进制形式,基数还是2. 现给你一十进制数n,问其可转化成多少种冗余二进制形式. 首先要想到:2x = 2*2x-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 ...
- 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 ...
- Integer Numbers
ZOJ Problem Set - 3365 Integer Numbers Time Limit: 1 Second Memory Limit: 32768 KB Special ...
- 利用Python【Orange】结合DNA序列进行人种预测
http://blog.csdn.net/jj12345jj198999/article/details/8951120 coursera上 web intelligence and big data ...
随机推荐
- Android webview 运行时不调用系统自带浏览器
WebView mobView = new WebView(this); mobView.loadUrl("http://www.csdn.net"); WebSettings w ...
- Fragment-生命周期
Fragment生命周期图 一.Fragment的几种状态: 与Activity类似,Fragment也有一下几种状态: · 活动状态:当前Fragment位于前台,可见,可获得焦点. · 暂停状态: ...
- 上市公司恋上互联网金融 目前已有14家涌入P2P
时至今日,互联网金融已蔚然成风,诸多上市公司正前赴后继介入到P2P业务中,据记者初步统计,目前至少有14家A股上市公司参与了P2P业务.央行6月份的报告显示,中国当前有600多家P2P公司,交易额达到 ...
- Kinect开发 —— 基础知识
转自:http://www.cnblogs.com/yangecnu/archive/2012/04/02/KinectSDK_Application_Fundamentals_Part2.html ...
- 00082_Set接口
1.Set接口介绍 (1)Collection中可以存放重复元素,也可以不存放重复元素,那么我们知道List中是可以存放重复元素的.那么不重复元素给哪里存放呢?那就是Set接口,它里面的集合,所存储的 ...
- Interrupt distribution scheme for a computer bus
A method of handling processor to processor interrupt requests in a multiprocessing computer bus env ...
- 【开卷故意】JAVA正則表達式模版
专业既然是机器学习.那工作肯定也是继续和数据打交道,那么问题来了,非常多时候推荐算法和数据挖掘算法都是现成可用的,平台初建,重点还在数据过滤和抽取.如何高效的抽取数据? 利用往常算法比赛中经常使用的字 ...
- Oracle APEX 4.2公布RESTful Webservice
Purpose This tutorial covers creating a RESTful Web Service and accessing the Web Service through an ...
- HDU1023 Train Problem II【Catalan数】
题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=1023 题目大意: 一列N节的火车以严格的顺序到一个站里.问出来的时候有多少种顺序. 解题思路: 典型 ...
- java初始化过程中成员变量
package day01; class Base{ int j; //1.j=0 Base(){ add(1); //2.调用子类add()方法 System.out.println(j); //4 ...