U E D R , A S I H C RSS

The Priest Mathematician/김상섭

~cpp
#include <iostream>
using namespace std;
#include <vector>
#include <cmath>
unsigned int hanoi[10001] = {0,1,};
int a[10000];

int main()
{
	vector<int> test;
	int num;
	unsigned min, temp;
	for(int i = 1; i < 10001; i++)
	{
		min = 4000000000;
		for(int k = 0; k < i; k++)
		{
			temp = 2*hanoi[k] +pow(2,i-k) -1;
			if(temp <= min)
			{
				min = temp;
				a[i] = k;
			}
		}

		hanoi[i] = min;
	}

	for(i = 1; i < 30; i++)
		cout << i << "  " << a[i] << "  " << hanoi[i] << endl;

	while(cin >> num)
		test.push_back(num);

	for(vector<int>::iterator j = test.begin(); j != test.end(); j++)
		cout << hanoi[*j] << endl;

	return 0;
}
Valid XHTML 1.0! Valid CSS! powered by MoniWiki
last modified 2021-02-07 05:28:14
Processing time 0.0073 sec