알고리즘 문제 풀기/HackerRank
HackerRank - Cats and a Mouse
bug_maker
2019. 1. 31. 09:16
https://www.hackerrank.com/challenges/cats-and-a-mouse/problem
HackerRank - Cats and a Mouse
#!/bin/python3import mathimport osimport randomimport reimport sysdef catAndMouse(x, y, z): catA = x - z catB = y - z output = '' if(catA < 0): catA = catA * -1 if(catB < 0): catB = catB * -1 if(catA == catB): output = 'Mouse C' elif(catA > catB): output = 'Cat B' elif(catA < catB): output = 'Cat A' return outputif __name__ == '__main__': fptr = open(os.environ['OUTPUT_PATH'], 'w') q = int(input()) for q_itr in range(q): xyz = input().split() x = int(xyz[0]) y = int(xyz[1]) z = int(xyz[2]) result = catAndMouse(x, y, z) fptr.write(result + '\n') fptr.close()