Re: mathematical combination
- From: user923005 <dcorbit@xxxxxxxxx>
- Date: Wed, 21 Nov 2007 12:05:13 -0800 (PST)
On Nov 21, 10:44 am, keny...@xxxxxxxxx wrote:
Hi!
I'm new to C++ but I have a challenge to write a program to find the
different mathematical combinations of p and t objects respectively
from a total of n objects i.e. nCp and nCt.The program should display
the various combinations.
A further aspect is to find the intersection between nCp and nCt
i.e.each set of nCp that contains each of the possible combinations of
nCt without considering the order of appearance.
Let me try to be clearer,pls:
say n=7,p=5 and t=3
1. I want a program to find 7C5 and 7C3
2. I want a display of the possible combinations in each case i.e
for 7C5; (12345),(12346),(12347),(13456)etc and
for 7C3; (123),(124),(125),(126)etc
3. Finally, the intersection e.g.
(123) intersects (12345),(12346),...
(124) intersects (12345),(12346)...
(125) intersects (12345)
and so on.
Your help will be appreciated.Thanks.
Look up "Pascal's Triangle" for a table lookup approach to the nCr
problem.
Do you know what your domain is? In other words can you have 200 C
5? How about 1000 C 7?
If the domain is large, it will quicky become infeasible to list the
combinations. For instance, this is the Pascal's Triangle table for
n=100:
static const long double d100[] =
{
1.
,100.
,4950.
,161700.
,3921225.
,75287520.
,1192052400.
,16007560800.
,186087894300.
,1902231808400.
,17310309456440.
,141629804643600.
,1050421051106700.
,7110542499799200.
,44186942677323600.
,253338471349988640.
,1345860629046814650.
,6650134872937201800.
,30664510802988208300.
,132341572939212267400.
,535983370403809682970.
,2041841411062132125600.
,7332066885177656269200.
,24865270306254660391200.
,79776075565900368755100.
,242519269720337121015504.
,699574816500972464467800.
,1917353200780443050763600.
,4998813702034726525205100.
,12410847811948286545336800.
,29372339821610944823963760.
,66324638306863423796047200.
,143012501349174257560226775.
,294692427022540894366527900.
,580717429720889409486981450.
,1095067153187962886461165020.
,1977204582144932989443770175.
,3420029547493938143902737600.
,5670048986634686922786117600.
,9013924030034630492634340800.
,13746234145802811501267369720.
,20116440213369968050635175200.
,28258808871162574166368460400.
,38116532895986727945334202400.
,49378235797073715747364762200.
,61448471214136179596720592960.
,73470998190814997343905056800.
,84413487283064039501507937600.
,93206558875049876949581681100.
,98913082887808032681188722800.
,100891344545564193334812497256.
};
When you display your results, is order important?
.
- References:
- mathematical combination
- From: kenyem1
- mathematical combination
- Prev by Date: Re: Places to purchase PowerBASIC?
- Next by Date: Wanted: Java script automatic refresh browser and capture new added text/postings with notification
- Previous by thread: mathematical combination
- Next by thread: Re: mathematical combination
- Index(es):
Relevant Pages
|