느낀점 및 설명

배도 고픈데 왜 아무도 안오는겨..ㅠ.ㅜ
이제 그만짤랭~! 씽..위키나 짜야지..

소스


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

using namespace std;

int GetSolomonGolombNumber(int pointNumber)
{
	map<int, int> numbers;
	int nowNumber = 1;
	register int suchNumber;
	for (register int i = 1; nowNumber < pointNumber; ++i)
	{
		numbers[nowNumber] = i;
		
		for(suchNumber = i; numbers.end() == numbers.find(suchNumber); --suchNumber);

		nowNumber += numbers[suchNumber];
	}
	for(suchNumber = pointNumber; numbers.end() == numbers.find(suchNumber); --suchNumber);

	return numbers[suchNumber];
}

void main()
{
	int calculateNumber = 0;
	while(1)
	{
		cin >> calculateNumber;
		if (0 == calculateNumber)
			break;
		cout << GetSolomonGolombNumber(calculateNumber) << endl;
	}
}
Retrieved from http://wiki.zeropage.org/wiki.php/Self-describingSequence/조현태
last modified 2021-02-07 05:28:00