U E D R , A S I H C RSS

Hartal/Celfin

~cpp
#include <iostream>
using namespace std;

int testcase, testdays, partyNum, i, j;
int party[100];
bool hartal[3651];
int counting;

int getHartal()
{
	counting=0;
	for(i=0; i<partyNum; i++)
	{
		for(j=1; j<3650; j++)
		{
			if(party[i]*j>testdays)
				break;
			if(hartal[party[i]*j])
			{
				counting++;
				hartal[party[i]*j]=false;
			}
		}
	}
	return counting;
}

int main()
{
	cin >> testcase;
	while(testcase--)
	{
		cin>>testdays;
		for(i=1; i<testdays+1; i++)
		{
			if(i%7==0 || i%7==6)
				hartal[i]=false;
			else
				hartal[i]=true;
		}
		cin>>partyNum;
		for(i=0; i<partyNum; i++)
			cin >>party[i];
		cout << getHartal()<< endl;
	}
	return 0;
}
Valid XHTML 1.0! Valid CSS! powered by MoniWiki
last modified 2021-02-07 05:23:22
Processing time 0.0129 sec