[HIHO1177]顺子(暴力,枚举)

题目链接:http://hihocoder.com/problemset/problem/1177

我不知道python为什么,加了排序会RE??

 1 d = {'J':11,'Q':12,'K':13,'A':14}
 2 vc = set([])
 3 def g(v):
 4   vc.add(v[1])
 5   if len(v[0]) == 2 or v[0] not in d:
 6     return int(v[0])
 7   return int(d[v[0]])
 8 s = sorted(map(g, map(lambda x: (x[:-1], x[-1]), raw_input().split(' '))))
 9 f, ex = 0, 0
10 for i in range(1, 4):
11   if s[i] - s[i-1] == 1: continue
12   elif s[i] - s[i-1] == 2:
13     if f == 0: f = 1
14     else: ex = 1
15   else: ex = 1
16 if ex == 1: print '0/1'
17 else:
18   if f == 1:
19     if len(vc) == 1: print '1/16'
20     else: print'1/12'
21   else:
22     if len(vc) == 1:
23       if s[0] == 2 or s[3] == 14: print '1/16'
24       else: print'1/8'
25     else:
26       if s[0] == 2 or s[3] == 14: print '1/12'
27       else: print'1/6'
原文地址:https://www.cnblogs.com/kirai/p/6421057.html