神奇的立方数
Time Limit:1000MS Memory Limit:65536K
Total Submit:719 Accepted:235
Description
zjahstu 是一个数学“粉丝”,总相信立方数有某种神奇的魔力(为什
么呢?^V^)。于是他拜托你写一个程序来判断一个数是否是立方数.
Input
输入包含多个不超过 10000 个整数 A,范围为[-2^31,2^31-1],
Output
输出每一个数是否是立方数,是则输出 Yes,否则输出 No
Sample Input
0
1
27
36
Sample Output
YES
YES
YES
NO
Source
ahstu@ICPC02
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace AK1017 {
class Program {
static void Main(string[] args) {
string sb;
while ((sb = Console.ReadLine()) != null) {
int n = int.Parse(sb);
bool flag = false;
for (int i = -1400; i <= 1400; i++) {
if (i * i * i == n) {
flag = true;
break;
}
}
if (flag)
Console.WriteLine("YES");
else
Console.WriteLine("NO");
//if (n < 0) n = -n;
//int x = (int)Math.Pow(n, 1.0/3);
////x = Math.Floor(x);
////Console.WriteLine(x);
//if (x * x * x == n)
// Console.WriteLine("YES");
//else
// Console.WriteLine("NO");
}
}
}
}