110,536
社区成员
发帖
与我相关
我的任务
分享
static void Main(string[] args)
{
int X = 0;//需要判断的数
while (true)
{
Console.WriteLine("Please Enter:");
X =Convert.ToInt16(Console.ReadLine());
int[] aa = { 1, 2, 4, 8, 16, 32 };
List<int> ls = new List<int>();
for (int i = 0; i < aa.Length; i++)
{
for (int k = 0; k < aa.Length; k++)
{
for (int y = i + 1; y < aa.Length - k; y++)
{
int count = aa[i];
for (int n = 0; n < k + 1; n++)
{
count += aa[y + n];
}
ls.Add(count);
}
}
}
bool f = true;
for (int i = 0; i < ls.Count; i++)
{
if (ls[i] == X)
{
Console.WriteLine("Yes");
f = false;
break;
}
}
if (f)
Console.WriteLine("No");
}
}