hdu 4431 Mahjong 模拟
来源:互联网 发布:淘宝客域名注册技巧 编辑:程序博客网 时间:2024/04/20 10:05
#include<bits/stdc++.h>using namespace std;int cnt[50],t[50];int judge1(){ for(int i=0;i<34;i++) { if(cnt[i]==2||cnt[i]==0) ; else return 0; } return 1;}int judge2(){ int sum=0; if(cnt[0]&&cnt[8]&&cnt[9]&&cnt[17]&&cnt[18]&&cnt[26]) { sum=cnt[0]+cnt[8]+cnt[9]+cnt[17]+cnt[18]+cnt[26]; } else return 0; for(int i=0;i<7;i++) { if(cnt[27+i]) sum+=cnt[27+i]; else return 0; } if(sum==14)return 1; else return 0;}int judge4(){ int i,j,sum=0; for(i=0;i<34;i++) t[i]=cnt[i]; for(i=0;i<=18;i+=9) for(j=0;j<9;j++) { if(t[i+j]>=3) { t[i+j]-=3; sum++; } while(j+2<9&&t[i+j]&&t[i+j+1]&&t[i+j+2]) { sum++; t[i+j]--; t[i+j+1]--; t[i+j+2]--; } } for(i=0;i<7;i++) if(t[i+27]>=3) { t[i+27]-=3; sum++; } if(sum==4) return 1; else return 0;}int judge3(){ int i; for(i=0;i<34;i++) { if(cnt[i]>=2) { cnt[i]-=2; if(judge4()) { cnt[i]+=2; return 1; } cnt[i]+=2; } } return 0;}int judge(){ if(judge1()||judge2()||judge3()) return 1; else return 0;}int main(){ int _,i,t,use[50],ans; char c; scanf("%d",&_); while(_--) { ans=0; memset(cnt,0,sizeof(cnt)); memset(use,0,sizeof(use)); for(i=0;i<13;i++) { scanf("%d%c",&t,&c); t--; if(c=='m') t+=0; else if(c=='s') t+=9; else if(c=='p') t+=18; else if(c=='c') t+=27; cnt[t]++; } for(i=0;i<34;i++) { cnt[i]++; if(cnt[i]<=4&&judge()) { ans++; use[i]=1; } cnt[i]--; } if(ans) { printf("%d",ans); for(i=0;i<34;i++) { if(use[i]==0) continue; t=i%9; if(i/9==0) printf(" %dm",t+1); else if(i/9==1) printf(" %ds",t+1); else if(i/9==2) printf(" %dp",t+1); else printf(" %dc",t+1); } printf("\n"); } else printf("Nooten\n"); } return 0;}
0 0
- hdu - 4431 - Mahjong - 模拟
- hdu 4431 Mahjong 模拟
- hdu 4431 Mahjong (模拟+搜索)
- HDU 4431 Mahjong 搜索 模拟
- hdu 4431 Mahjong (模拟)
- HDU 4431 Mahjong(枚举,模拟)
- HDU 4431 Mahjong (模拟) #by Plato
- hdu 4431 Mahjong (模拟,枚举+dfs)
- hdu 4431 Mahjong(dfs+模拟)
- HDU 4431 Mahjong 2012天津A题 模拟题
- HDU 4431 Mahjong (麻将、神坑模拟题)
- 假期训练——Mahjong HDU - 4431 模拟
- Mahjong HDU 4431
- HDU 4431 Mahjong
- HDU 4431 Mahjong
- HDU 4431 Mahjong
- 枚举+搜索 hdu-4431-Mahjong
- HDU 4431 Mahjong(天津赛区亚洲区) 模拟题,方法很重要
- /*捕食者与被捕食者求大神解题C++.*/
- 项目4——数值转换
- C++ AES之CBC加密模式
- 观察者模式
- Java学习中遇到的一些问题
- hdu 4431 Mahjong 模拟
- 如何完全删除SQL Server2008。
- angular debug 调试
- 产生和为0的一组随机数
- 全景:Bundle adjustment算法
- 1.3.5 head.s开始执行(2)
- 找出s的子串中字典序第k小的“半回文串” Trie Codeforce Div. 2 Ann and Half-Palindrome
- 使用c#,WPF,模仿IPhone的Loading(加载)效果
- 如何设置插入的Toolbar资源中按钮保持按下状态