Блог пользователя sumit93

Автор sumit93, 9 лет назад, По-английски
My code


LLI rec(int room,int col)
{
if(room==0&&col==0)
return 1;
if(room==0||col==0)
return 0;
LLI &ans=dp[room][col];
if(ans!=-1)
return ans;
ans=0;
for(LLI i=1; i<=room; i++)
{
LLI temp=nCr(room,i)%mod;
temp=(temp*rec(room-i,col-1))%mod;
ans+=temp;
ans=ans%mod;
}
return ans%mod;
}

I am using this recursive dp to solve a problem.Suppose I have 200rooms and 35 colours. Here mod=1000000007. I have to colour every room using 35 colurs and every colour must be used.My function gives me wrong output. But I think it shoul give me correct otput. if room=200 and colour=35 , my function output: 872158314. But correct output shoul be : 35727139.Can anybody explain my logical bug in my function.

  • Проголосовать: нравится
  • -11
  • Проголосовать: не нравится

»
9 лет назад, # |
  Проголосовать: нравится +1 Проголосовать: не нравится

Please explain the problem better, Its not clear to me. Thanks.