当前位置:网站首页>hdu 1333 Smith Numbers(暴力思路)
hdu 1333 Smith Numbers(暴力思路)
2022-08-09 20:11:00 【51CTO】
题目: http://acm.hdu.edu.cn/showproblem.php?pid=1333
Smith Numbers
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 1734 Accepted Submission(s): 567
Problem Description
While skimming his phone directory in 1982, Albert Wilansky, a mathematician of Lehigh University, noticed that the telephone number of his brother-in-law H. Smith had the following peculiar property: The sum of the digits of that number was equal to the sum of the digits of the prime factors of that number. Got it? Smith’s telephone number was 493-7775. This number can be written as the product of its prime factors in the following way:
4937775 = 3 * 5 * 5 * 65837
The sum of all digits of the telephone number is 4+9+3+7+7+7+5= 42?, and the sum of the digits of its prime factors is equally 3+5+5+6+5+8+3+7= 42. Wilansky was so amazed by his discovery that he named this kind of numbers after his brother-in-law: Smith numbers.
As this observation is also true for every prime number, Wilansky decided later that a (simple and unsophisticated) prime number is not worth being a Smith number, so he excluded them from the definition.
Wilansky published an article about Smith numbers in the Two Year College Mathematics Journal and was able to present a whole collection of different Smith numbers: For example, 9985 is a Smith number and so is 6036. However,Wilansky was not able to find a Smith number that was larger than the telephone number of his brother-in-law. It is your task to find Smith numbers that are larger than 4937775!
Input
The input consists of a sequence of positive integers, one integer per line. Each integer will have at most 8 digits. The input is terminated by a line containing the number 0.
Output
For every number n > 0 in the input, you are to compute the smallest Smith number which is larger than n, and print it on a line by itself. You can assume that such a number exists.
Sample Input
Sample Output
分析:
smith number:除素数外,所有位的数的和等于该数字的所有素因子的所有位上的数字的和。
输入的数字是最多8位,int不是最多10位吗?估摸着用int应该没有问题。就是一个数字一个数字的试。
边栏推荐
- Redis 大的情况下,key 要如何处理?
- hdu 3341 Lost's revenge(dp+Ac自动机)
- Reverse Analysis of Unknown Cryptographic Protocol Based on Network Data Flow
- 威纶通触摸屏制作自定义弹出窗口的具体方法(3种)
- Skywalking系列学习之Trace Profiling源码分析
- SqlServer 2016 安装相关问题
- How to deal with keys when Redis is large?
- PMP每日一练 | 考试不迷路-8.8(包含敏捷+多选)
- Number of daffodils within a thousand
- 获取数组最后一项别再用array.length-1了
猜你喜欢

字节二面问的MySQL,差点没答好

URL Protocol web page to open the application

普源精电上半年扭亏为盈,高端产品持续发力!你看好仪器界“华为”吗?

DSPE-PEG-Azide,DSPE-PEG-N3,磷脂-聚乙二醇-叠氮可和DBCO直接反应

编程时请选择正确的输入法,严格区分中英文

leetcode 二叉树的分层遍历1

企业数据打通有什么好处?不同行业怎么解决数据打通难题?

蓝牙模块的分类和对应的属性特点

【图文并茂】如何进行Win7系统的重装

Puyuan Jingdian turned losses into profits in the first half of the year, and high-end products continued to develop!Are you optimistic about "Huawei" in the instrument industry?
随机推荐
poj 3070 Fibonacci(简单矩阵连乘)
哪款C语言编译器(IDE)适合初学者?
source install/setup.bash时出现错误
What to do if Windows 11 can't find Internet Explorer
获取一段程序运行的时间
Reverse Analysis of Unknown Cryptographic Protocol Based on Network Data Flow
How to deal with keys when Redis is large?
不经意传输协议OT
Visual studio 2022 debugging skills introduction
基于模糊PID控制器的水温控制系统仿真
UE4_定序器控制蓝图对象
Ankerui supports Ethernet communication, profibus communication embedded energy meter APM guiding technical requirements-Susie Week
【深度学习】pix2pix GAN理论及代码实现
matlab 神经网络 ANN 分类
XXE-XML外部实体注入-知识点
How are data integration APIs key to enterprise digital transformation?
Unity_物体自转
Word怎么设置图片衬于文字下方?两种方法教你设置Word图片衬于文字下方
别叫我玩,我要考PMP:考PMP选择机构需要了解的那些事儿
Application of Acrel5000web Energy Consumption System in a College-Susie Week