topic:
Several kinds of card type
X Xiao Ming was hijacked to Las Vegas, was forced to play cards with three other people.
A deck of cards (remove ace size, a total of 52), evenly distributed to four people, each person 13.
At this time, Xiao Ming mind suddenly emerge a question:
If you do not consider the color, only consider points not consider the order of the cards they receive, their own hands to get the initial card type combination, a total of how many do?
Please fill in the integer, do not fill in any extra content or captions.
analysis:
Current cards are five possible, a 1 is not to take, is to take a 2, 3 is to take two, take three 4, 5 is to take four, then it can be solved DFS, when the number of cards reached 13 and the current brand label reaches 13 it means to find a.
Code:
#include <iostream>
#include <cstdio>
#include <cstring>
using namespace std;
int ans;
void Dfs(int ind,int sum)
{
if(ind > 13 || sum > 13) return;
if(ind==13&&sum==13)
{
ans++;
return;
}
for(int i=0;i<=4;++i)
Dfs(ind+1,sum+i); //对应着下一张扑克拿i张
}
int main()
{
Dfs(0,0);
printf("%d\n",ans);
return 0;
}