春天是鮮花的季節,水仙花就是其中最迷人的代表,數學上有個水仙花數,他是這樣定義的: 「水仙花數」是指乙個三位數,它的各位數字的立方和等於其本身,比如:153=1^3+5^3+3^3。 現在要求輸出所有在m和n範圍內的水仙花數。
輸入資料有多組,每組佔一行,包括兩個整數m和n(100<=m<=n<=999)。
對於每個測試例項,要求輸出所有在給定範圍內的水仙花數,就是說,輸出的水仙花數必須大於等於 m,並且小於等於n,如果有多個,則要求從小到大排列在一行內輸出,之間用乙個空格隔開; 如果給定的範圍內不存在水仙花數,則輸出no; 每個測試例項的輸出佔一行。
#input
copy
100 120300 380
no370 371
using system;using system.collections.generic;
using system.linq;
using system.text;
namespace 水仙花數
*/ m = convert.toint32(s1[0]);
n = convert.toint32(s1[1]);
"m = " + m + "n = " + n);
if (m > n)
//m = math.min(m, n);
//n = math.max(m, n);
// cout << m << " " << n << endl;
int flag = 0;
for (int i = m; i <= n; ++i)
}if (flag == 0)
console.write("no");
console.writeline();}}
static int calc(int n)
return sum;}}
}
oj的測試資料只有兩個(哈哈),所以用下面的這個就可以ac
using system;using system.collections.generic;
using system.linq;
using system.text;
namespace 水仙花數1
}}
水仙花數問題
problem description 春天是鮮花的季節,水仙花就是其中最迷人的代表,數學上有個水仙花數,他是這樣定義的 水仙花數 是指乙個三位數,它的各位數字的立方和等於其本身,比如 153 1 3 5 3 3 3。現在要求輸出所有在m和n範圍內的水仙花數。input 輸入資料有多組,每組佔一行,...
C 水仙花數
include include using namespace std void divide int,int int int void main int hun 0,ten 0,one 0 for int i 100 i 999 i divide i,hun,ten,one if i pow hu...
「水仙花」數的問題
problem description 春天是鮮花的季節,水仙花就是其中最迷人的代表,數學上有個水仙花數,他是這樣定義的 水仙花數 是指乙個三位數,它的各位數字的立方和等於其本身,比如 153 1 3 5 3 3 3。現在要求輸出所有在m和n範圍內的水仙花數。輸入 輸入資料有多組,每組佔一行,包括兩...