import sys queryTimes = int(input()) for i in range(queryTimes): line = input() n = int(line) count = 0 length = len(line) for ch in line: if(int(ch) == 0 or n % int(ch) == 0): # print(int(ch)) count += 1 if(count == length): print("G") elif(count == 0): print("S") else: print("H")
还以为要对数字去重,没想到不用。