hdu 1165 Eddy's research II (DP)

点击打开链接

当m=1时:
A(1,n) = A(0,A(1,n-1)) = A(1,n-1)+1
= A(0,A(1,n-2))+1 = A(1,n-2)+2.....
= A(1,n-n)+n = A(0,1)+n=n+2;
当m=2时:
A(2,n) = A(1,A(2,n-1)) = A(2,n-1)+2
= A(1,A(2,n-2))+2=A(2,n-2)+2*2...
= A(2,n-n)+2*n = 2*n+3;
当m=3时:
A(3,n) = A(2,A(3,n-1)) = 2*(A(3,n-1))+3;

 

#include"stdio.h"
__int64 A(__int64 m,__int64 n)
{
	if(n==0) return A(m-1,1);
	else if(m==1) return n+2;
	else if(m==2) return 2*n+3;
	else return 2*(A(3,n-1))+3;
}
int main()
{
	__int64 n,m;
	while(scanf("%I64d%I64d",&m,&n)!=EOF)
		printf("%I64d\n",A(m,n));
	return 0;
}

你可能感兴趣的:(hdu 1165 Eddy's research II (DP))