设为首页 加入收藏

TOP

模拟斗地主――HDU 4930(二)
2015-07-20 17:48:58 来源: 作者: 【 】 浏览:11
Tags:模拟 斗地主 HDU 4930
A有炸弹且比B大,Yes,否则如果B有炸弹,No;之后判断其他(顺序随便)。。。

#include
  
   
#include
   
     #include
    
      #include
      #include
      
        #include
       
         #include
        
          #include
         
           #include
          
            #include
           
             #include
            
              const int MAXN=1000+10; using namespace std; struct Card//保存两人手里各种组牌(如3夹2,4夹2等等)的最大值 { Card(){one=0;two=0;three=0;three_1=0;three_2=0;four=0;four_2=0;xy=0;len=0;} int one,two,three,three_1,three_2,four,four_2,xy,len; }; void cal(char *s, int *num)//计算各种牌有多少个,如num[14]表示A有num[14]张 { for(int i=0; i
             
              =2) c.two=i; if(num[i]>=3) c.three=i; if(num[i]>=4) c.four=i; if(num[i]>=4 && c.len>=6) c.four_2=i; if(num[i]>=3 && c.len>=5){ for(int j=1; j<=15; j++) if(i!=j && num[j]>=2) {c.three_2=i;break;} } if(num[i]>=3 && c.len>=4) c.three_1=i; } } bool first(char *s, Card c)//判断能否一次出完 { int len=strlen(s); if(c.xy && 2==len) return 1; if(c.four && 4==len) return 1; if(c.four_2 && 6==len) return 1; if(c.three_2 && 5==len) return 1; if(c.three_1 && 4==len) return 1; if(c.three && 3==len) return 1; if(c.two && 2==len) return 1; if(c.one && 1==len) return 1; return 0; } int main() { //freopen("in.txt","r",stdin); char s1[20],s2[20]; int T; scanf("%d", &T); while(T--) { scanf("%s%s", s1,s2); Card c1,c2; c1.len=strlen(s1); c2.len=strlen(s2); int num1[20]={0},num2[20]={0}; cal(s1,num1); cal(s2,num2); attack(c1,num1); attack(c2,num2); if(first(s1,c1)) {printf("Yes\n");continue;}//一次出完 if(c1.xy) {printf("Yes\n");continue;}//有王炸 if(c2.xy) {printf("No\n");continue;}//对方有王炸 if(c1.four && c1.four >= c2.four) {printf("Yes\n");continue;}//有炸弹且比对方大 else {if(c2.four) {printf("No\n");continue;}}//这里也错了不少次。。。 if(c1.three_2 && c1.three_2 >= c2.three_2) {printf("Yes\n");continue;}//有3夹2且比对方大 if(c1.one >= c2.one) {printf("Yes\n");continue;}//单张比对方大 if(c1.two && c1.two >= c2.two) {printf("Yes\n");continue;}//有对子且比对方大 if(c1.three && c1.three >= c2.three) {printf("Yes\n");continue;}//有3条且比对方大 if(c1.three_1 && c1.three_1 >= c2.three_1) {printf("Yes\n");continue;}//有3夹1且比对方大 printf("No\n"); } return 0; } 
             
            
           
          
         
        
       
      
    
   
  


首页 上一页 1 2 下一页 尾页 2/2/2
】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
分享到: 
上一篇POJ 1459 Power Network (多源点.. 下一篇C++设计模式之适配器模式(三)

评论

帐  号: 密码: (新用户注册)
验 证 码:
表  情:
内  容:

·如何利用Python做数 (2025-12-24 23:48:36)
·如何使用python进行 (2025-12-24 23:48:34)
·python 爬虫入门该怎 (2025-12-24 23:48:31)
·Java 实现多个大文件 (2025-12-24 23:22:00)
·Java多线程编程在工 (2025-12-24 23:21:56)