# 2006百度之星程序设计大赛预赛题目之饭团的烦恼 参考解答

#include <string>
#include <vector>
#include <fstream>
#include <iostream>
#include <stdio.h>
#include "math.h"

using namespace std;

struct food
{
string name;
int price;
bool isHun;
bool isXinla;
};

static int nFoodNeed; //饭团需要点的菜的数目
static int nPeople; //就餐的人数

//荤菜，素菜，辛辣，清淡菜
static int nHunFood;
static int nSuFood;
static int nXinFood;
static int nQindanFood;

{   //所选菜与15元相差多少
// test price
int totalPrice = 0;
{
totalPrice += (*iter).price;
}
return abs(totalPrice/nPeople - 15); //8折
}

{
double priceDistance = 1e+308;
double thisDistance = 0.0;
{
thisDistance = Distance15yuan(*iter);
if(thisDistance < priceDistance)
{
priceDistance = thisDistance;
}
}
}

bool TestCondition(vector<food> chosenFood)
{   //是否符合荤菜，素菜，辛辣，清淡菜数量要求
int nTestHunFood = 0;
int nTestSuFood = 0;
int nTestXinFood = 0;
int nTestQindanFood = 0;
for(vector<food>::iterator iter = chosenFood.begin(); iter != chosenFood.end(); ++iter)
{
if((*iter).isHun == true)
{
++nTestHunFood;
}
else
{
++nTestSuFood;
}
}
if(nTestHunFood != nHunFood)
{
return false;
}
if(nTestSuFood != nSuFood)
{
return false;
}

for(vector<food>::iterator iter = chosenFood.begin(); iter != chosenFood.end(); ++iter)
{

if((*iter).isXinla == true)
{
++nTestXinFood;
}
else
{
++nTestQindanFood;
}
}
if(nTestXinFood != nXinFood)
{
return false;
}
if(nTestQindanFood != nQindanFood)
{
return false;
}

return true;
}

{
if(leftFood.size() == nFoodNeed)
{
if(TestCondition(leftFood) == true)
{
}
return;
}

for(vector<food>::iterator iter = rightFood.begin(); iter != rightFood.end(); ++iter)
{
vector<food> newLeftFood(leftFood);
newLeftFood.push_back(*iter);
vector<food> newRightFood;

for(vector<food>::iterator i = iter+1; i != rightFood.end(); ++i)
{
newRightFood.push_back(*i);
}

}
}

void TryToSolove()
{
vector<food> left;
}

int main(int argc, char* argv[])
{
ifstream is(argv[1], ios::in | ios::binary);

is >> nFoodNeed;
is >> nPeople;
food temp;

for(int i = 0; i < nFoodMenu; ++i)
{
is >> temp.name;
is >> temp.price;
is >> temp.isHun ;
is >> temp.isXinla;
}
is >> nHunFood;
is >> nSuFood;
is >> nXinFood;
is >> nQindanFood;
TryToSolove();
double averagePrice = 0.0;
{
cout << (*iter).name << endl;
averagePrice += (*iter).price;
}

printf("%0.2f/n", averagePrice/nPeople*0.8);

return 0;
}

#### 2015年百度之星程序设计大赛 - 初赛(1) 【题解】

2015-06-01 19:13:35

#### 2006 年百度之星程序设计大赛初赛题目---座位调整--菜鸟学习算法

2012-09-23 00:47:20

#### 2015年百度之星程序设计大赛 - 初赛(2)【题解】

2015-06-02 16:54:30

#### 2006年百度之星程序设计大赛试题初赛题目-题5-座位调整

2012-05-18 20:06:44

#### 【TEST】2017百度之星程序设计大赛 - 复赛

2017-09-02 10:14:25

#### 2017"百度之星"程序设计大赛 - 初赛（B）Chess(水题)

2017-08-13 14:50:43

#### HDU-2017"百度之星"程序设计大赛-复赛-1003-Pokémon GO

2017-08-18 16:47:38

#### 2017"百度之星"程序设计大赛-初赛（A） 比赛总结

2017-08-17 22:25:00

#### 百度之星程序设计大赛题目

2011年06月20日 364KB 下载

#### 2017"百度之星"程序设计大赛 - 初赛（A）

2017-08-12 19:54:17