It seams quite a simple problem, but I always got WA....
I use dp to solve it? but failed...
My dp format is like
Code: Select all
Accepted :D
anything wrong or there is some tricky input?
any help will do...
Thx in advance..
Moderator: Board moderators
Code: Select all
Accepted :D
Code: Select all
*
* a strike, if Bob's number is greater than X
* a smile, if Bob's number is less than X
* a stop, if Bob's number is precisely X
*
dp(i,j) = min guess (i numbers with at most j strikes). Answer is obviously dp(n,m-1).Nursoltan_h wrote:How to solve using dp? I'm stuck at it.
Code: Select all
for(i=1;i<21;i++)
{
ar[i][1]=1;
ar[1][i]=i;
}
for(i=2;i<21;i++)
{
for(j=2;j<=55;j++)
{
ar[i][j]=1+ar[i-1][j-1]+ar[i][j-1];
}
}