#include<bits/stdc++.h> using namespace std; string ss[5]; string tt[5]; int num=0; map<char,int> mp; //map<char,char> cc; int x,x1,x2,x3,x4,x5; int y,y1,y2,y3,y4,y5; bool up(string xx,string yy){return mp[xx[0]]<mp[yy[0]];} void mm() { sort(ss,ss+5,up); int c=0,s=0,d=0,h=0; for(int i=0;i<=4;i++) { if(ss[i][1]=='C') c++; if(ss[i][1]=='S') s++; if(ss[i][1]=='D') d++; if(ss[i][1]=='H') h++; } if(c==5||s==5||d==5||h==5) // 6 9 10; { int t=1; if(mp[ss[0][0]]+1!=mp[ss[1][0]])t=0; if(mp[ss[1][0]]+1!=mp[ss[2][0]])t=0; if(mp[ss[2][0]]+1!=mp[ss[3][0]])t=0; if(mp[ss[3][0]]+1==mp[ss[4][0]] || (mp[ss[3][0]]==5&&mp[ss[4][0]]==14) ) t=t; else t=0; // else if(mp[ss[3][0]]==5 && mp[ss[4][0]]==14) t=t; // else t=0; if(t==0) {x=6; x1=mp[ss[4][0]]; x2=mp[ss[3][0]]; x3=mp[ss[2][0]]; x4=mp[ss[1][0]]; x5=mp[ss[0][0]];} else {x=9; x1=mp[ss[4][0]]; x2=mp[ss[3][0]]; x3=mp[ss[2][0]]; x4=mp[ss[1][0]]; x5=mp[ss[0][0]];} return ; } if(1)// 2 3 4 7 8 { if(mp[ss[1][0]]==mp[ss[0][0]] &&mp[ss[2][0]]==mp[ss[0][0]] &&mp[ss[3][0]]==mp[ss[0][0]] ) { x=8; x1=mp[ss[0][0]]; x2=mp[ss[4][0]]; return ;// 2 2 2 2 3 *********************************** } if(mp[ss[1][0]]==mp[ss[4][0]] &&mp[ss[2][0]]==mp[ss[4][0]] &&mp[ss[3][0]]==mp[ss[4][0]] ) { x=8; x1=mp[ss[4][0]]; x2=mp[ss[0][0]]; return ;// 2 3 3 3 3 ************************************ } if(mp[ss[1][0]]==mp[ss[0][0]] &&mp[ss[2][0]]==mp[ss[0][0]] && mp[ss[3][0]]==mp[ss[4][0]] ) { x=7; x1=mp[ss[0][0]]; x2=mp[ss[4][0]];return ;// 2 2 2 3 3 +++++++++++++++++++++++++++ } if(mp[ss[3][0]]==mp[ss[4][0]] &&mp[ss[2][0]]==mp[ss[4][0]] && mp[ss[1][0]]==mp[ss[0][0]] ) { x=7; x1=mp[ss[4][0]]; x2=mp[ss[0][0]]; return ;// 3 3 4 4 4 ++++++++++++++++++++++++++ } if(mp[ss[1][0]]==mp[ss[0][0]] &&mp[ss[2][0]]==mp[ss[0][0]] ) { x=4; x1=mp[ss[0][0]]; x2=mp[ss[4][0]]; x3=mp[ss[3][0]]; return ;// 2 2 2 3 4 -------------------------- } if(mp[ss[2][0]]==mp[ss[1][0]] &&mp[ss[3][0]]==mp[ss[1][0]] ) { x=4; x1=mp[ss[1][0]];x2=mp[ss[4][0]]; x3=mp[ss[0][0]]; return ;// 2 3 3 3 4 -------------------------- } if(mp[ss[4][0]]==mp[ss[2][0]] &&mp[ss[3][0]]==mp[ss[2][0]] ) { x=4; x1=mp[ss[2][0]];x2=mp[ss[1][0]]; x3=mp[ss[0][0]]; return ;// 2 3 4 4 4 --------------------------- } if(mp[ss[1][0]]==mp[ss[0][0]] &&mp[ss[2][0]]==mp[ss[3][0]] ) { x=3; x1=mp[ss[3][0]]; x2=mp[ss[1][0]]; x3=mp[ss[4][0]]; return ; // 2 2 3 3 4 ------------- ------ } if(mp[ss[1][0]]==mp[ss[2][0]] &&mp[ss[3][0]]==mp[ss[4][0]] ) { x=3; x1=mp[ss[4][0]]; x2=mp[ss[2][0]]; x3=mp[ss[0][0]]; return ;// 2 3 3 4 4 ------------ -------- } if(mp[ss[1][0]]==mp[ss[0][0]] &&mp[ss[3][0]]==mp[ss[4][0]] ) { x=3; x1=mp[ss[4][0]]; x2=mp[ss[1][0]]; x3=mp[ss[2][0]]; return ;// 2 2 3 4 4 ------------ -------- } if(mp[ss[1][0]]==mp[ss[0][0]]) {x=2; x1=mp[ss[0][0]]; x2=mp[ss[4][0]]; x3=mp[ss[3][0]]; x4=mp[ss[2][0]]; return ;} // 2 2 3 4 5 if(mp[ss[2][0]]==mp[ss[1][0]]) {x=2; x1=mp[ss[1][0]]; x2=mp[ss[4][0]]; x3=mp[ss[3][0]]; x4=mp[ss[0][0]]; return ;} // 2 3 3 4 5 if(mp[ss[3][0]]==mp[ss[2][0]]) {x=2; x1=mp[ss[2][0]]; x2=mp[ss[4][0]]; x3=mp[ss[1][0]]; x4=mp[ss[0][0]]; return ;} // 2 3 4 4 5 if(mp[ss[4][0]]==mp[ss[3][0]]) {x=2; x1=mp[ss[3][0]]; x2=mp[ss[2][0]]; x3=mp[ss[1][0]]; x4=mp[ss[0][0]]; return ;} // 2 3 4 5 5 } if(1)// 1 5 { int t=1; if(mp[ss[0][0]]+1!=mp[ss[1][0]]) t=0; if(mp[ss[1][0]]+1!=mp[ss[2][0]]) t=0; if(mp[ss[2][0]]+1!=mp[ss[3][0]]) t=0; if(mp[ss[3][0]]+1==mp[ss[4][0]] || (mp[ss[3][0]]==5&&mp[ss[4][0]]==14) ) t=t; else t=0; //else if(mp[ss[3][0]]==5 && mp[ss[4][0]]==14) t=t ; // else t=0; if(t==1) {x=5; x1=mp[ss[4][0]]; x2=mp[ss[3][0]]; x3=mp[ss[2][0]]; x4=mp[ss[1][0]]; x5=mp[ss[0][0]];} else {x=1; x1=mp[ss[4][0]]; x2=mp[ss[3][0]]; x3=mp[ss[2][0]]; x4=mp[ss[1][0]]; x5=mp[ss[0][0]];} return ; } } void make() { x=0,x1=0,x2=0,x3=0,x4=0,x5=0; y=0,y1=0,y2=0,y3=0,y4=0,y5=0; mm(); y=x; y1=x1;y2=x2; y3=x3; y4=x4; y5=x5; x=0,x1=0,x2=0,x3=0,x4=0,x5=0; ss[0]=tt[0];ss[1]=tt[1]; ss[2]=tt[2]; ss[3]=tt[3]; ss[4]=tt[4]; mm(); if(y>x) {num++;return;}if(y<x)return ; if(y1>x1){num++;return;}if(y1<x1) return ; if(y2>x2){num++;return;}if(y2<x2) return ; if(y3>x3){num++;return;}if(y3<x3) return ; if(y4>x4){num++;return;}if(y4<x4) return ; if(y5>x5){num++;return;}if(y5<x5) return ; return ; } int main() { mp['2']=2;mp['3']=3;mp['4']=4;mp['5']=5; mp['6']=6; mp['7']=7;mp['8']=8;mp['9']=9;mp['T']=10; mp['J']=11; mp['Q']=12; mp['K']=13; mp['A']=14; // cc['C']=1; cc['S']=2; cc['D']=3; cc['H']=4; freopen("1.txt","r",stdin); for(int i=1;i<=1000;i++) { for(int j=0;j<=4;j++)cin>>ss[j]; // for(int j=0;j<=4;j++)cout<<ss[j]<<" "; for(int j=0;j<=4;j++)cin>>tt[j]; //for(int j=0;j<=4;j++)cout<<ss[j]<<" "; make(); } cout<<num<<endl; }
Project Euler 54
猜你喜欢
转载自www.cnblogs.com/Andromeda-Galaxy/p/10396878.html
今日推荐
周排行