CodeForces Round #444 (Div.2)
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了CodeForces Round #444 (Div.2)相关的知识,希望对你有一定的参考价值。
A. Div. 64
题意
问你能不能去掉一些0和1使这个二进制数整除64
题解
就是判断100000是不是个子串
1 str = input() 2 l = len(str) 3 flag = 0 4 ok = 0 5 for i in range(l - 1, -1, -1): 6 if flag < 6 and str[i] == ‘0‘: 7 flag = flag + 1 8 elif flag == 6 and str[i] == ‘1‘: 9 ok = 1 10 if ok: 11 print(‘yes‘) 12 else: 13 print(‘no‘)
B. Cubes for Masha
题意
略
题解
暴力
1 d = [] 2 n = int(input()) 3 4 class dice: 5 def __init__(self, line): 6 s = line.split() 7 self.a = [] 8 for i in range(6): 9 self.a.append(int(s[i])) 10 self.l = 6 11 12 def isValid(x): 13 if x < 10: 14 for cur in d: 15 for i in cur.a: 16 if x == i: 17 return True 18 elif x < 100: 19 for i in range(n): 20 for p in d[i].a: 21 for j in range(n): 22 if i == j: 23 continue 24 for q in d[j].a: 25 y = p * 10 + q 26 if x == y: 27 return True 28 else: 29 for i in range(n): 30 for j in range(n): 31 if i != j: 32 for k in range(n): 33 if k != i and k != j: 34 for p in d[i].a: 35 for q in d[j].a: 36 for r in d[k].a: 37 y = 100 * p + 10 * q + r 38 if x == y: 39 return True 40 return False 41 42 for i in range(n): 43 d.append(dice(input())) 44 ans = 0 45 for i in range(1, 1000): 46 if isValid(i): 47 ans = i 48 else: 49 break 50 print(i - 1)
C. Solution for Cube
题意
给定一个骰子, 问一次90°的旋转能否复原
题解
总共三个方向, 6种旋转, 模拟一下就好了
1 line = input().split() 2 a = [] 3 for i in line: 4 a.append(int(i)) 5 6 def isValid(b): 7 flag = 0 8 if b[flag] != b[flag + 1] or b[flag + 1] != b[flag + 2] or b[flag + 2] != b[flag + 3]: 9 return False 10 flag = 4 11 if b[flag] != b[flag + 1] or b[flag + 1] != b[flag + 2] or b[flag + 2] != b[flag + 3]: 12 return False 13 flag = 8 14 if b[flag] != b[flag + 1] or b[flag + 1] != b[flag + 2] or b[flag + 2] != b[flag + 3]: 15 return False 16 flag = 12 17 if b[flag] != b[flag + 1] or b[flag + 1] != b[flag + 2] or b[flag + 2] != b[flag + 3]: 18 return False 19 flag = 16 20 if b[flag] != b[flag + 1] or b[flag + 1] != b[flag + 2] or b[flag + 2] != b[flag + 3]: 21 return False 22 flag = 20 23 if b[flag] != b[flag + 1] or b[flag + 1] != b[flag + 2] or b[flag + 2] != b[flag + 3]: 24 return False 25 return True 26 27 def rotate(): 28 q = [] 29 for i in a: 30 q.append(i) 31 q[4], q[6], q[8], q[10], q[21], q[23], q[0], q[2] = q[0], q[2], q[4], q[6], q[8], q[10], q[21], q[23] 32 if isValid(q): 33 return True 34 q.clear() 35 for i in a: 36 q.append(i) 37 q[0], q[2], q[4], q[6], q[8], q[10], q[21], q[23] = q[4], q[6], q[8], q[10], q[21], q[23], q[0], q[2] 38 if isValid(q): 39 return True 40 # 41 q.clear() 42 for i in a: 43 q.append(i) 44 q[12], q[13], q[4], q[5], q[16], q[17], q[20], q[21] = q[20], q[21], q[12], q[13], q[4], q[5], q[16], q[17] 45 if isValid(q): 46 return True 47 q.clear() 48 for i in a: 49 q.append(i) 50 q[20], q[21], q[12], q[13], q[4], q[5], q[16], q[17] = q[12], q[13], q[4], q[5], q[16], q[17], q[20], q[21] 51 if isValid(q): 52 return True 53 # 54 q.clear() 55 for i in a: 56 q.append(i) 57 q[15], q[13], q[2], q[3], q[16], q[18], q[9], q[8] = q[2], q[3], q[16], q[18], q[9], q[8], q[15], q[13] 58 if isValid(q): 59 return True 60 q.clear() 61 for i in a: 62 q.append(i) 63 q[2], q[3], q[16], q[18], q[9], q[8], q[15], q[13] = q[15], q[13], q[2], q[3], q[16], q[18], q[9], q[8] 64 if isValid(q): 65 return True 66 return False 67 68 if rotate(): 69 print(‘YES‘) 70 else: 71 print(‘NO‘)
D.
E.
F.
以上是关于CodeForces Round #444 (Div.2)的主要内容,如果未能解决你的问题,请参考以下文章
Codeforces Round #444 (Div. 2) B. Cubes for Masha 暴力枚举
Codeforces Round #436 E. Fire(背包dp+输出路径)
Educational Codeforces Round 131 div.2 A-F题解
Educational Codeforces Round 131 div.2 A-F题解