HDU 1197 Specialized Four-Digit Numbers
Specialized Four-Digit Numbers
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 7358 Accepted Submission(s): 5415
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
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.)
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.
2993
2994
2995
2996
2997
2998
2999
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cstdio>
#include <vector>
#include <queue>
#include <cstdlib>
#include <iomanip>
#include <cmath>
#include <ctime>
#include <map>
#include <set>
using namespace std;
#define lowbit(x) (x&(-x))
#define max(x,y) (x>y?x:y)
#define min(x,y) (x<y?x:y)
#define MAX 100000000000000000
#define MOD 1000000007
#define pi acos(-1.0)
#define ei exp(1)
#define PI 3.141592653589793238462
#define INF 0x3f3f3f3f3f
#define mem(a) (memset(a,0,sizeof(a)))
typedef long long ll;
int main()
{
for(int i=;i<=;i++)
{
int n=i;
int k=i;
int m=i;
int ans=,pos=,cnt=;
while(n)
{
ans+=n%;
n/=;
}
while(m>=)
{
cnt+=m%;
m/=;
}
cnt+=m;
while(k>=)
{
pos+=k%;
k/=;
}
pos+=k;
if(pos==ans && ans==cnt) printf("%d\n",i);
}
return ;
}
HDU 1197 Specialized Four-Digit Numbers的更多相关文章
- HDU 1197 Specialized Four-Digit Numbers (枚举+进制转化,简单)
题意:让求从2992-9999中所有数字,满足10进制各位之和和12进制和16进制各位数字之和相等. 析:没啥可说的,只能枚举从2992-9999,每个进制都算一下. 代码如下: #include & ...
- HDOJ 1197 Specialized Four-Digit Numbers
Problem Description Find and list all four-digit numbers in decimal notation that have the property ...
- 【HDOJ】1197 Specialized Four-Digit Numbers
水题,暴力可解. #include <iostream> using namespace std; int chg(int n, int base); int main() { int i ...
- HDU 6659 Acesrc and Good Numbers (数学 思维)
2019 杭电多校 8 1003 题目链接:HDU 6659 比赛链接:2019 Multi-University Training Contest 8 Problem Description Ace ...
- HDU 2817 A sequence of numbers
http://acm.hdu.edu.cn/showproblem.php?pid=2817 __int64 pow_mod (__int64 a, __int64 n, __int64 m)快速幂取 ...
- hdu 5676 ztr loves lucky numbers
题目链接:hdu 5676 一开始看题还以为和数位dp相关的,后来才发现是搜索题,我手算了下,所有的super lucky number(也就是只含数字4, 7且4, 7的数量相等的数)加起来也不过几 ...
- HDU 2817 A sequence of numbers 整数快速幂
A sequence of numbers Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Ot ...
- HDU 5676 ztr loves lucky numbers (模拟)
ztr loves lucky numbers 题目链接: http://acm.hust.edu.cn/vjudge/contest/121332#problem/I Description ztr ...
- HDOJ(HDU) 2138 How many prime numbers(素数-快速筛选没用上、)
Problem Description Give you a lot of positive integers, just to find out how many prime numbers the ...
随机推荐
- CentOS6 安装 aria2
CentOS6 安装 aria2 https://www.jianshu.com/p/31ea7aba5524 http://blog.51cto.com/skypegnu1/1637168 1.先安 ...
- WireGuard 隧道的安装和使用,测试地址 ca.6tu.me
WireGuard 端到端平等的网络隧道,测试地址 ca.6tu.me --------------------------------------------- 服务器:远程 Ubuntu18 , ...
- BZOJ 1066 Dinic
思路: 网络流 建边比较麻烦 //By SiriusRen #include <queue> #include <cstdio> #include <cstring> ...
- netflix zuul 1.x与zuul2.x之比较
1.zuul 1.x的架构如下所示: 线程模型: 其web应用的web.xml <?xml version="1.0" encoding="UTF-8"? ...
- AIX 系统补丁格式
AIX 系统版本标准格式: 5300-06-11-0918 VR00-TL-SP-YYWW 5300-06-11-0918 ^-------- YYWW(2009年第 ...
- Deepin for Linux 下串口调试交换机
最近因工作需要,在淘宝购买了一条宇泰的串口线:USB to RS232 之所以选择这款,主要是它支持 Windows.Linux.mac Linux机是Deepin for Linux,算是国产比较好 ...
- 2018上半年GitHub上最热门的开源项目
关注GitHub的人都知道,这个平台上面有太多优秀的值得学习的开源项目了,这里总结了2018上半年GitHub上最热门的开源项目. 1: tensorflow https://github.com/t ...
- sleep实现原理
用户程序中的睡眠: sleep() usleep() nanosleep() sleep()和nanosleep()都是使进程睡眠一段时间后被唤醒,但是二者的实现完全不同.Linux中并没 ...
- Codeforces 472D
看官方题解提供的是最小生成树,怎么也想不明确.you can guess and prove it! 看了好几个人的代码.感觉实现思路全都不一样,不得不佩服cf题目想法的多样性 以下说说我自己的理解, ...
- js---13 this call apply
//this:this可以写在js全剧环境中(全局环境中this是window对象),this可以写在函数中,可以写在对象中, function f(){ this.name = "asdf ...