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 ...
随机推荐
- Service绑定模式
Service绑定模式 使用绑定的Service能够实现组件与Service的通信. 组件与被绑定的Service能够不归属于同一个应用程序.因此通过绑定Service能够实现进程间通信. ...
- Linux系统的LOG日志文件及入侵后日志的清除
UNIX网管员主要是靠系统的LOG,来获得入侵的痕迹.当然也有第三方工具记录入侵系统的 痕迹,UNIX系统存放LOG文件,普通位置如下: /usr/adm - 早期版本的UNIX/var/adm - ...
- Spring MVC 注解式
1.注解式控制器简介 一.Spring2.5之前,我们都是通过实现Controller接口或其实现来定义我们的处理器类.已经@Deprecated. 二.Spring2.5引入注解式处理器支持,通 ...
- 设计兼容不同的屏幕尺寸的Android界面
Android的屏幕类型有几百种不同的尺寸,从小型的手机到大型的电视机.因此要使我们的应用程序兼容不同屏幕尺寸,才可以让我们的应用提供给更多的用户使用. 一.支持不同的屏幕尺寸 1.使用"w ...
- Coderfroces 864 D. Make a Permutation!
D. Make a Permutation! Ivan has an array consisting of n elements. Each of the elements is an intege ...
- 利用canvas画一个实时时钟
先放一张效果图: 下面是源代码: <!DOCTYPE html> <html> <head> <meta charset="UTF-8"& ...
- linux安装lrzsz支持rz从windows上传文件到linux
1.下载lrzsz wget https://wangxuejin-data-1252194948.cos.ap-shanghai.myqcloud.com/lrzsz-0.12.20.tar.gz ...
- U-BOOT启动流程分析--start_armboot函数(二)
第二阶段的功能: 初始化本阶段所需的硬件设备(主要设置系统时钟.初始化串口.Flash.网卡.USB) 检测系统内存映射(memory map) 将内核映像和根文件系统映象从Flash上读到RAM空间 ...
- python note #3
Hello, guys! I found it pretty difficult to get my content according to my key words. So in this not ...
- Android学习总结(2)——App客户端与服务器交互中的token
学习Token Token是什么? Token是服务端生成的一串字符串,以作客户端进行请求的一个令牌,当第一次登录后,服务器生成一个Token便将此Token返回给客户端,以后客户端只需带上这个Tok ...