水仙花数
Time Limit:1000MS Memory Limit:65536K
Total Submit:627 Accepted:201
Description
输出区间[a,b】中的所有水仙花数,若三位数ABC满足ABC=A^3+B^3+C^3,则称为水仙花数。例如153=1^3+5^3+3^3,所以 153是水仙花数
Input
一个区间【a,b】,b>a>0
Output
输出区间[a,b】中的所有水仙花数(每一个1行)
Sample Input
100 154
Sample Output
Hint
153
Source
lrj程序入门
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace AK1114 {
class Program {
static void Main(string[] args) {
int a, b, x, y, z, i;
string[] values = Console.ReadLine().Split(' ');
a = int.Parse(values[0]); b = int.Parse(values[1]);
if (a < 100) a = 100;
if (b > 999) b = 999;
for (i = a; i <= b; i++) {
x = i / 100;
y = i / 10 % 10;
z = i % 10;
if (x * x * x + y * y * y + z * z * z == i)
Console.WriteLine(i);
}
}
}
}