问题描述:
hzf 最近迷上 QQ 游戏欢乐斗牛。
斗牛的规则如下,游戏开始的时候,每位玩家发 5张扑克牌,每张牌都是 A-K 中的一张牌(1 表示 A,2−10表示对应的牌,11-J,12-Q,13-K)。每张牌都有一个点数,1−10分别对应其点数,11−13对应点数 10。牌型分为以下 5 种情况,牌型的优先级按照给定从上到下。
1.四炸——5张牌中有 4张牌相同 ,优先级最高。
2.五小牛——即五张牌点数都小于 5,且 5张牌的点总数和小于或等于 10,优先级次之。
3.牛牛——其中 3 张牌的点数和是 10 的整数倍,另外 2张牌的点数和是 10的整数倍。
4.牛 x(x=1,2,3…9)——其中 3张牌的点数和是 10的整数倍,另外 2张牌的点数和对 10取模为x。
5.以上情况都不是,就是无牛。
hzf 要根据自己的牌型来决定自己的下注的倍数,但是 hzf 总是不能看出他的牌型,你能写一个程序帮助他吗。
输入格式
一行输入 5个空格隔开的整数。
输出格式
若牌型为四炸,输出一行quadra bomb orz。
若为五小牛,输出一行penta calf。
若为牛牛,输出一行you can you up。
若为牛 x,输出一行too young too simple:calf x。
若为无牛,输出一行gg.
样例输入1
10 10 10 1 1
样例输出1
too young too simple:calf 2
样例输入2
10 10 10 10 9
样例输出2
quadra bomb orz
代码解析:
#include <iostream>
#include <algorithm>
using namespace std;
//a[]represent the five cards
int a[5];
//quadra bomb orz
bool re1(){
sort(a,a+5);
if(a[0]==a[1]&&a[1]==a[2]&&a[2]==a[3])return 1;
if(a[1]==a[2]&&a[2]==a[3]&&a[3]==a[4])return 1;
return 0;
}
//penta calf
bool re2(){
//default
for(int i=0;i<5;i++){
if(a[i]>10)a[i]=10;
}
//total
int total=0;
for(int i=0;i<5;i++){
if(a[i]>=5)return 0;
total=total+a[i];
}
if(total>10)return 0;
return 1;
}
//you can you up
bool re3(){
int sum=0;
for(int i=0;i<5;i++){
sum+=a[i];
}
for(int i=0;i<5;i++){
for(int j=i+1;j<5;j++){
for(int k=j+1;k<5;k++){
if((a[i]+a[j]+a[k])%10==0&&sum%10==0)
return 1;
}
}
}
return 0;
}
//too young too simple:
bool re4(){
for(int i=0;i<5;i++){
for(int j=i+1;j<5;j++){
for(int k=j+1;k<5;k++){
if((a[i]+a[j]+a[k])%10==0)
return 1;
}
}
}
return 0;
}
//main
int main() {
//
while(scanf("%d %d %d %d %d",&a[0],&a[1],&a[2],&a[3],&a[4])!=EOF){
if(re1()){
printf("quadra bomb orz\n");
continue;
}
if(re2()){
printf("penta calf\n");
continue;
}
if(re3()){
printf("you can you up\n");
continue;
}
if(re4()){
printf("too young too simple:calf %d\n",(a[0]+a[1]+a[2]+a[3]+a[4])%10);
continue;
}
printf("gg\n");
continue;
}
return 0;
}