U E D R , A S I H C RSS

Hartals/상협재동

Hartals/상협재동

~cpp 

#include <iostream>
using namespace std;

int term;
int numberOfHartal;

int hartal[100] = {0,};
int strike[3650] = {0,};
int totalStrike[100] = {0,};

void input();
void process(int num);
void output(int testCase);
void arrayInit(int* array, int arrayNum);

void arrayInit(int* array, int arrayNum)
{
	for(int i = 0; i < arrayNum; i++)
		array[i] = 0;
}

void main()
{
	int testCase;
	cin >> testCase;

	for(int i = 0; i < testCase; i++)
	{	
		arrayInit(hartal, 100);
		arrayInit(strike, 3650);

		input();
		process(i);
	}

	output(testCase);
}

void input()
{
	
	cin >> term;
	cin >> numberOfHartal;

	for(int i = 0; i < numberOfHartal; i++)
	{
		cin >> hartal[i];
	}
}

void process(int num)
{
	for(int i = 0; i < numberOfHartal; i++)
	{
		for(int j = hartal[i] - 1; j < term; j += hartal[i])
		{
			strike[j]++;
		}
	}

	for(i = 0; i < term; i++)
	{
		if(i % 7 != 5 && i % 7 != 6)
		{
			if(strike[i] > 0)
			{
				totalStrike[num]++;
			}
		}
	}
}

void output(int testCase)
{
	for(int i = 0; i < testCase; i++)
		cout << totalStrike[i] << endl;
}


Valid XHTML 1.0! Valid CSS! powered by MoniWiki
last modified 2021-02-07 05:23:22
Processing time 0.0199 sec