1 from __future__ import PRint_function 2 3 4 def main(): 5 t = int(raw_input()) 6 for _ in range(t): 7 n = int(raw_input()) 8 a = int(raw_input()) 9 b = int(raw_input())10 possible_value = []11 for _ in range(n):12 temp_value = (_ * a + (n - 1 - _) * b) # 抽象化理解題目的意思13 if temp_value not in possible_value:14 possible_value.append(temp_value)15 possible_value.sort() # 使用list結構的方便性16 for _ in possible_value:17 print(_, end = ' ') # 使用Dash幫助自己理解這個函數18 print()19 main()
Link:
https://www.hackerrank.com/challenges/manasa-and-stones
學習:
Dash的輔助使用
怎樣修改相應的參數
調用合適的函數
合理數據結構的選用
做題時候選用合適的數據結構
新聞熱點
疑難解答