Q:
小明被劫持到X赌城,被迫与其他3人玩牌。
一副扑克牌(去掉大小王牌,共52张),均匀发给4个人,每个人13张。
这时,小明脑子里突然冒出一个问题:
如果不考虑花色,只考虑点数,也不考虑自己得到的牌的先后顺序,自己手里能拿到的初始牌型组合一共有多少种呢?
请填写该整数,不要填写任何多余的内容或说明文字。
Code:
int ans = 0;
void bfs(int gain, int type){
if(gain > 13 || type > 13) return;
if(gain == 13 && type <= 13){ ans++; return;}
for(int i = 0; i <= 4; i++)//for each type of card, you can fetch 0~4
bfs(gain+i, type+1);//no matter how many cards you fetch, the type should plus 1
}
int main(){
bfs(0, 0);
printf("Time used = %.2f\n", (double)clock() / CLOCKS_PER_SEC);
cout << ans << endl;
printf("Time used = %.2f\n", (double)clock() / CLOCKS_PER_SEC);
return 0;
}
answer
3598180