題目描述
在征服南極之后,Davor 開始了一項新的挑戰。下一步是在西伯利亞、格林蘭、挪威的北極圈遠征。
他將在 2018 年 12 月 31 日開始出發,在這之前需要一共籌集 n 元錢。
他打算在每個星期一籌集 x 元,星期二籌集 x+k 元,……,星期日籌集 x+6k 元,并連續籌集 52 個星期。其中 x,k 為正整數,并且滿足 1≤x≤100。
現在請你幫忙計算 x,k 為多少時,能剛好籌集 n 元。
如果有多個答案,輸出 x 盡可能大,k 盡可能小的。注意 k 必須大于 0。
輸入格式
The first line of input contains the integer N (1456 ≤ N ≤ 145600), the number from the task.
輸出格式
The first line of output must contain the value of X (0 < X ≤ 100 ), and the second the value of
K (K > 0 ).
輸入輸出樣例
輸入
1456
輸出
1
1
方式-解方程
代碼
class Solution:@staticmethoddef oi_input():"""從標準輸入讀取數據"""num = int(input())return num@staticmethoddef oi_test():"""提供測試數據"""return 1456@staticmethoddef solution(num):'''平均一天 為x + 3kk為自變量 x為因變量由k 返回去找 x由于只需要找x最大的,所以 k由小到大'''for k in range(1, num):if num / 364 - 3 * k <= 100: # k為自變量 x為因變量x = num / 364 - 3 * kprint(int(x))print(k)breakoi_input = Solution.oi_input
oi_test = Solution.oi_test
solution = Solution.solutionif __name__ == '__main__':num = oi_test()# num = oi_input()solution(num)