一个算数题,我做不完了,先去开会,下午回来继续
(42494,36946,22800,33650,28796,20400,36200,34396,27750,30350,18796,18900,35894)分成哪几个相加会得出这两个数199100与188272
提问完毕。
程序代码:using System;
namespace testdatetostr
{
class Program
{
static void Main(string[] args)
{
long result;
const long OK = 199100;
long[] array = { 42494, 36946, 22800, 33650, 28796, 20400, 36200, 34396, 27750, 30350, 18796, 18900, 35894 };
string str = "";
for (int i = 1; i < 8192; i++)
{
str = Convert.ToString(i, 2).PadLeft(13,'0');
result = 0;
for(int j=0;j<13;j++)
{
if(str[j] == '1')
result += array[j];
if (result == OK)
goto lable1;
if (result > OK)
break;
}
}
Console.WriteLine("None");
Console.ReadKey();
return;
lable1: Console.WriteLine(str);
Console.ReadKey();
}
}
}
