程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
 程式師世界 >> 編程語言 >> C語言 >> C++ >> C++入門知識 >> USACO Section 2.1 Healthy Holsteins

USACO Section 2.1 Healthy Holsteins

編輯:C++入門知識

USACO Section 2.1 Healthy Holsteins


/*
ID: lucien23
PROG: holstein
LANG: C++
*/

#include 
#include 
#include 
using namespace std;

bool compFun(int x, int y)
{
	int temp, i = 0;

	while (true)
	{
		temp = 1 << i;
		if (temp&x > temp&y)
		{
			return true;
		} else if (temp&x < temp&y)
		{
			return false;
		}
		i++;
	}
}

int main()
{
	ifstream infile("holstein.in");
	ofstream outfile("holstein.out");
	if(!infile || !outfile)
	{
		cout << "file operation failure!" << endl;
		return -1;
	}

	int arrCnt[15] = {1,3,7,15,31,63,127,255,511,1023,2047,4095,8191,16383,32767};

	int V;
	infile >> V;
	int *minRequire = new int[V];
	for (int i=0; i> minRequire[i];
	}
	int G;
	infile >> G;
	int **feeds = new int *[G];
	for (int i=0; i> feeds[i][j];
		}
	}

	int minScoopsCnt = 16;
	int minScoops = 0;

	int *sumVita = new int[V];
	int sumScoops;
	for (int i=1; i<=arrCnt[G-1]; i++)
	{//窮舉遍歷每一種方案
		for (int k=0; k

  1. 上一頁:
  2. 下一頁:
Copyright © 程式師世界 All Rights Reserved