U E D R , A S I H C RSS

Hanoi Tower Troubles Again!/하기웅

2006.1.17

느낌

  • 그냥 간단한 계산식을 구해버렸다.

소스 코드

~cpp
#include <iostream>
using namespace std;

int testcase, i;
int test[51];

int counting(int num)
{
	if(num%2==0)
		return 2*(num/2)*(num/2) + 2*(num/2)-1;
	else
		return (num+1)*(num+1)/2-1;
}

int main()
{
	cin>>testcase;
	for(i=1; i<testcase+1; i++)
		cin>>test[i];
	for(i=1; i<testcase+1; i++)
		cout << counting(test[i]) <<endl;
	return 0;
}
Valid XHTML 1.0! Valid CSS! powered by MoniWiki
last modified 2009-05-27 07:09:19
Processing time 0.0081 sec