G - Specialized Four-Digit Numbers(1.5.2)
Time Limit:1000MS Memory Limit:65536KB 64bit IO Format:%I64d
& %I64u
cid=1006#status//G/0" class="ui-button ui-widget ui-state-default ui-corner-all ui-button-text-only" style="font-family:Verdana,Arial,sans-serif; font-size:1em; border:1px solid rgb(211,211,211); background-color:rgb(227,228,248); color:rgb(85,85,85); display:inline-block; position:relative; padding:0px; margin-right:0.1em; zoom:1; overflow:visible; text-decoration:none">Status
Description
(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
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)的更多相关文章
- [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 ...
- 【Kickstart】2017 Round (Practice ~ G)
Practice Round Problem A Country Leader (4pt/7pt) Problem B Vote (5pt/8pt) Problem C Sherlock and Pa ...
- PAT/进制转换习题集
B1022. D进制的A+B (20) Description: 输入两个非负10进制整数A和B(<=230-1),输出A+B的D (1 < D <= 10)进制数. Input: ...
- js判断小数点几位
js如何判断小数点后有几位 <script> var n=3.143423423;alert(n.toString().split(".")[1].length); & ...
- 数据结构——POJ 1686 Lazy Math Instructor 栈的应用
Description A math instructor is too lazy to grade a question in the exam papers in which students a ...
- 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 ...
随机推荐
- python + selenium - selenium简介
1. 产品简介 selenium 是 基于 web网页的UI自动化测试框架. 1)支持多浏览器操作:ie.chrome.firefox.edge.safaria等 2)跨平台:windows.linu ...
- doc下设置永久环境变量的好方法
http://www-2w.blog.163.com/blog/static/97931518201021211123267/ 需要查看命令具体实现:setx machine “%path%”. 配置 ...
- hihoCoder #1072 辅导
题意 $\DeclareMathOperator{\lcm}{lcm}$选 $k$ ($k\le 10$) 个 $1$ 到 $n$($n\le 10^9$)之间的整数(可以相同),使得 $\lcm(a ...
- HDU——1013Digital Roots(九余数定理)
Digital Roots Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) To ...
- mybatis的双数据源创建
一.jdbc中: jdbc.driver=com.mysql.jdbc.Driver jdbc.url=jdbc:mysql://202.108.211.55:3306/app-apm?useUnic ...
- bzoj3238 [Ahoi2013]差异 后缀数组+单调栈
[bzoj3238][Ahoi2013]差异 Description Input 一行,一个字符串S Output 一行,一个整数,表示所求值 Sample Input cacao Sample Ou ...
- 【bzoj1717】[Usaco2006 Dec]Milk Patterns 产奶的模式 SA+二分
Description 农夫John发现他的奶牛产奶的质量一直在变动.经过细致的调查,他发现:虽然他不能预见明天产奶的质量,但连续的若干天的质量有很多重叠.我们称之为一个“模式”. John的牛奶按质 ...
- fzu 1753 质因数的应用
Another Easy Problem Time Limit:1000MS Memory Limit:32768KB 64bit IO Format:%I64d & %I64 ...
- poj 2079 Triangle
Triangle Time Limit: 3000MS Memory Limit: 30000K Total Submissions: 9835 Accepted: 2951 Descript ...
- poj 3168 Barn Expansion
Barn Expansion Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 2465 Accepted: 666 Des ...