Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 not understanding this problem
Index -> Programming, C++ -> C++ Help
Goto page Previous  1, 2
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
CodeMonkey2000




PostPosted: Sat Apr 11, 2009 11:44 pm   Post subject: RE:not understanding this problem

Actually I think there is a formula, and I think it is something like:

{2^(n-1)^2 + n^[(n+1)%2] }%98777
Sponsor
Sponsor
Sponsor
sponsor
Tony




PostPosted: Sat Apr 11, 2009 11:52 pm   Post subject: RE:not understanding this problem

n = 1
{2^(n-1)^2 + n^[(n+1)%2] }%98777
{2^(1-1)^2 + 1^[(1+1)%2] }%98777
{2^(0)^2 + 1^[(2)%2] }%98777
{1 + 1^[0] }%98777
= 2

But there is only 1 possibility

[*]
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
Analysis Mode




PostPosted: Sun Apr 12, 2009 12:49 am   Post subject: Re: not understanding this problem

special case?
saltpro15




PostPosted: Sun Apr 12, 2009 7:36 am   Post subject: RE:not understanding this problem

I don't like this question Sad I'm trying a shortest-path one now, i'll let you guys work on this one :p
DanielG




PostPosted: Sun Apr 12, 2009 9:26 am   Post subject: RE:not understanding this problem

codemonkey, how did you come up with the formula? or, if you found it, where did you find it?
bbi5291




PostPosted: Sun Apr 12, 2009 11:06 am   Post subject: Re: not understanding this problem

Actually, CodeMonkey2000's formula is very close... work out some small cases, and you should see a pattern emerge Smile it's not an excessively difficult problem, at least it is very easy to code.
CodeMonkey2000




PostPosted: Sun Apr 12, 2009 12:58 pm   Post subject: Re: RE:not understanding this problem

DanielG @ Sun Apr 12, 2009 9:26 am wrote:
codemonkey, how did you come up with the formula? or, if you found it, where did you find it?


2^(n-1)^2 is the number of (n-1) matrices you can have.The last column and last row needs to be fixed to accommodate the restrictions, and there are n ways if n is even and 0 ways if n is odd. The last part should be n*[(n+1)%2], that was a typo; my bad Razz That formula will give you 17 solutions when N=3

I was trying to do the problem last night, and tried to find a DP solution, but instead found a possible formula. It made sense to me last night Razz.

{2^(n-1)^2 + n*[(n+1)%2] }%98777 I think this is right, though I don't feel like coding up the solution, or signing up to the judge to verify. Someone should code a brute force solution, and verify the formula.
bbi5291




PostPosted: Sun Apr 12, 2009 1:12 pm   Post subject: Re: not understanding this problem

I thought it was clear from my previous post that this formula, while close, is not quite correct.
Sponsor
Sponsor
Sponsor
sponsor
Display posts from previous:   
   Index -> Programming, C++ -> C++ Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 2 of 2  [ 23 Posts ]
Goto page Previous  1, 2
Jump to:   


Style:  
Search: