U E D R , A S I H C RSS

Steps/조현태

느낀점 및 설명

또 시간이 남아서.. 또 간단한거 하나..
또 왜 아무도 안와아아!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

소스


~cpp
#include <iostream>
#include <Windows.h>
#include <vector>

using namespace std;

bool IsCanResize(int* targetNumber)
{
	if (*targetNumber == *(targetNumber + 1))
	{
		if (((*(targetNumber - 1) == *targetNumber) || (*(targetNumber - 1) - 1 == *targetNumber)) &&
			*targetNumber == *(targetNumber + 2))
		{
			return TRUE;
		}
	}
	return FALSE;
}

int GetNumbersSize(vector<int>& initNumbers)
{
	vector<int> makedNumbers;
	bool isChanged = FALSE;
	if (0 < initNumbers.size())
		makedNumbers.push_back(1);
	for (register int i = 1; i < (int)initNumbers.size(); ++i)
	{
		if (i < (int)initNumbers.size() - 2 && IsCanResize(&initNumbers[i]))
		{
			makedNumbers.push_back(i + 1);
			++i;
			isChanged = TRUE;
		}
		else
			makedNumbers.push_back(i);
	}
	if (isChanged)
		return GetNumbersSize(makedNumbers);
	return makedNumbers.size();
}

void main()
{
	int testCaseNumber;
	cin >> testCaseNumber;
	for (int i = 0; i < testCaseNumber; ++i)
	{
		int startNumber;
		int endNumber;
		cin >> startNumber >> endNumber;
		vector<int> initNumbers;
		for (register int j = startNumber; j < endNumber; ++j)
		{
			initNumbers.push_back(1);
		}
		cout << GetNumbersSize(initNumbers) << endl;
	}
}
----
Steps
Valid XHTML 1.0! Valid CSS! powered by MoniWiki
last modified 2009-05-27 07:09:19
Processing time 0.0963 sec