1114 -- 水仙花数

水仙花数

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);
                }
            }
        }
    }


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值