西电OJ - 1044 炸金花

2019-04-14 08:56发布

题目链接:http://acm.xidian.edu.cn/problem.php?id=1044 #include #include #include using namespace std; /**************************************************************************************************************** 题意:打扑克中的扎金花(俗称飘三叶),给定三张牌,求大于该牌面的种类数 思路; 1,直接想到了暴力,只有九个面值,复杂度不高 2,注意几点: a,相同的点数只有四张,不存在 5 5 3 < 5 5 5这种牌面,在对子中应该考虑 b,注意顺子只有7个,而不是9个 c,在散排牌面中,注意不能是顺子,且(3 5 7和5 7 3)为一种情况,用一个访问数组标记 d,散排牌面的 2 3 5 比所有豹子大,要考虑到 e,wa了一下午的点,牌面为对子时,该对子牌面的豹子应该排除,即豹子数只有8,而非9 3,细心写 if else,细心写for for for就OK了。 ****************************************************************************************************************/ int visit[10][10][10]; int main() { int T; cin>>T; while(T--) { int temp[3],f[3]; memset(visit,0,sizeof(visit)); for(int i = 0;i < 3;i ++) cin>>temp[i]; sort(temp,temp+3); int num=0; if(temp[0] == temp[1] && temp[1]== temp[2]) num=9-temp[0]+1; else if(temp[0]+1 == temp[1] && temp[1]+1 == temp[2]) num=9+9-temp[2]; else if(temp[0] == temp[1]){ num=(9-temp[0])*8+9-temp[2]+15; if(temp[2] < temp[1]) num-=1; } else if(temp[0] == temp[2]){ num=(9-temp[0])*8+9-temp[1]+15; if(temp[1] < temp[0]) num-=1; } else if(temp[1] == temp[2]){ num=(9-temp[1])*8+9-temp[0]+15; if(temp[0] < temp[1]) num-=1; } else{ //cout<<"num1= "<