U E D R , A S I H C RSS

Hartals/차영권

소감

2005/04/04 Accepted 0:00.002 64
nCase라는 변수없이 while(1)로만 묶어서 로봇에 돌리니까 '시간 초과'라는 결과가 나왔었다.흠;;

코드

~cpp 
// no10050 - Hartals 
#include <iostream.h> 

#define MAX_CASE 100
 
int main() 
{ 
	int nCase;
	int Save_Result[MAX_CASE];
	int n = 0;
	int i, j; 
	int count = 0;
	int nDays; 
	int nPoliticalparty; 
	bool *Days; 
	int *HartalParameter; 
	cin >> nCase;                 
	// 입력
	while (n < nCase)
	{
		cin >> nDays; 
		cin >> nPoliticalparty; 
		Days = new bool[nDays]; 
		HartalParameter = new int[nPoliticalparty]; 
		for (i=0 ; i<nPoliticalparty ; i++) 
			cin >> HartalParameter[i]; 
		// 계산 
		for (i=0 ; i<nPoliticalparty ; i++) 
		{ 
			j=HartalParameter[i]; 
			while (j <= nDays) 
			{ 
				if ((j-1)%7 == 5 || (j-1)%7 == 6 || Days[j-1] == true) 
					count--; 
				Days[j-1] = true; 
				j += HartalParameter[i]; 
				count++; 
			}        
		}
		Save_Result[n++]=count;
		count = 0;
	}
	for (i=0 ; i<n ; i++)
		cout << Save_Result[i] << endl;
	delete [] HartalParameter; 
	delete [] Days;  
	return 0; 
} 

나한테 할 말

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