UVa Problem 10050 Hartals (罢工)

// Hartals (罢工)
// PC/UVa IDs: 110203/10050, Popularity: B, Success rate: high Level: 2
// Verdict: Accepted
// Submission Date: 2011-05-23
// UVa Run Time: 0.012s
//
// 版权所有(C)2011,邱秋。metaphysis # yeah dot net
//
// 取天数模 7 的值,0 表示星期天,1 ~ 6 表示星期一至星期六,根据题意来判断那天是罢工日。
	
#include <iostream>
#include <vector>
	
using namespace std;
	
int calc_lost (vector < int > hartal, int days)
{
	vector < int > day;
	day.resize (days);
	
	for (int i = 0; i < days; i++)
		day[i] = 0;
	for (int i = 0; i < days; i++)
	{
		if (i % 7 != 5 && i % 7 != 6)
		{
			for (int j = 0; j < hartal.size (); j++)
				if ((i + 1) % hartal[j] == 0)
				{
					day[i] = 1;
					break;
				}
		}
	}
	
	int lost = 0;
	for (int i = 0; i < days; i++)
		if (day[i] == 1)
			lost++;
	
	return lost;
}
	
int main (int argc, char *argv[])
{
	int cases, parties, days;
	vector < int > hartal;
	
	cin >> cases;
	
	if (cases > 0)
	{
		for (int i = 0; i < cases; i++)
		{
			cin >> days;
			cin >> parties;

			hartal.resize (parties);

			for (int j = 0; j < parties; j++)
				cin >> hartal[j];

			cout << calc_lost (hartal, days) << endl;
		}
	}
	
	return 0;
}


你可能感兴趣的:(c,Date,vector)