1032 -- 水仙花数
来源:互联网 发布:软件资源网站 编辑:程序博客网 时间:2024/06/05 19:00
水仙花数
Time Limit:1000MS Memory Limit:65536K
Total Submit:831 Accepted:336
Description
请判断一个数是不是水仙花数。
其中水仙花数定义各个位数立方和等于它本身的三位数。
Input
有多组测试数据,每组测试数据以包含一个整数n(100<=n<1000)
输入0表示程序输入结束。
Output
如果n是水仙花数就输出Yes
否则输出No
Sample Input
1531540
Sample Output
YesNo
Source
C语言基础
using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace AK1032 { class Program { static bool jtahstu(int n) { int x = n % 10, y = n / 10 % 10, z = n / 100; if (x * x * x + y * y * y + z * z * z == n) return true; return false; } static void Main(string[] args) { string sb; while ((sb = Console.ReadLine()) != null) { int n = int.Parse(sb); if (n == 0) break; if (jtahstu(n)) Console.WriteLine("Yes"); else Console.WriteLine("No"); } } } }
0 0
- 1032 -- 水仙花数
- 【AKOJ】1032-水仙花数
- 水仙花数
- 水仙花数
- 水仙花数
- 水仙花数
- 水仙花数
- 水仙花数
- 水仙花数
- 水仙花数
- 水仙花数
- 水仙花数
- 水仙花数
- 水仙花数
- 水仙花数
- 水仙花数
- 水仙花数
- 水仙花数
- CodeForces 387B George and Round
- 服务器维护手记-crontab引起大量sendmail进程打死内存问题
- Android Animation 动画的使用方法和介绍
- leetcode 069 Sqrt(x)(难易度:Medium)
- 1031 -- 素数求和问题
- 1032 -- 水仙花数
- Android Animation 动画的使用方法和介绍
- 1033 -- 鸡兔同笼
- 1034 -- 梯形
- 从文本文件中读取数据排序并输出到文本
- django 1.8 官方文档翻译: 6-6-2 如何使用WSGI 部署
- LeetCode2.2.7(Remove Nth Node From End of List)
- 手机锂电池(lithium-ion battery)
- 实时搜索引擎Elasticsearch(2)——Rest API的使用