HDOJ 2010 水仙花数
来源:互联网 发布:可视化网页编辑软件 编辑:程序博客网 时间:2024/06/16 09:53
根据水仙花数的定义,求解就好。
package introduction;import java.util.Scanner;/** * Created by yangyuan on 2017/12/8. */public class Problem2010{ public static void main(String[] args) { Scanner scanner = new Scanner(System.in); int m, n; int[] all = new int[999 - 100 + 1]; while (scanner.hasNext()) { m = scanner.nextInt(); n = scanner.nextInt(); int index = 0; for (int i = m; i <= n; i++) if (daffodil(i)) all[index++] = i; if (index == 0) System.out.println("no"); else { for (int i = 0; i < index; i++) { System.out.print(all[i]); if (i != index - 1) System.out.print(" "); } System.out.println(); } } } public static boolean daffodil(final int x) { int sum = x % 10; sum = sum * sum * sum; int y = x; while ((y /= 10) != 0) { int a = y % 10; sum += a * a * a; } if (sum == x) return true; return false; }}
阅读全文
0 0
- HDOJ 2010 水仙花数
- hdoj 2010 水仙花数
- HDOJ 2010 水仙花数
- HDOJ 2010 水仙花数
- HDOJ 2010-水仙花数
- HDOJ 2010 水仙花数
- HDOJ-2010 水仙花数
- HDOJ 2010 水仙花数
- HDOJ 【C】 2010 水仙花数
- hdoj.2010 水仙花数 20140721
- C++ hdoj 2010 水仙花数
- HDOJ 2010 水仙花数(使用对象)
- hdoj 水仙花数
- hdoj 水仙花数
- [水题][第一阶段-简单操作][HDOJ-2010]水仙花数
- hdu 2010 水仙花数
- HDU 2010 水仙花数
- 2010 水仙花数
- EL表达式向select中赋值
- 泊松分布
- hdu1358—Period(循环串)
- 举例说明h权重标签在seo优化中的具体运用
- 我的web之旅
- HDOJ 2010 水仙花数
- centos 7 下编译安装python3.6.1
- linux守护进程
- 消息队列:ActiveMQ
- PATH环境变量-学习小记
- Kafka设计解析(六)- Kafka高性能关键技术解析
- Android攻击方式与安全分析
- AtCoder Beginner Contest 081 D
- 机器学习笔记(0)-统计学习方法与感知机