Re: [問卦] 線上等,問個數學問題,謝謝已回收

看板Gossiping作者 (小平)時間7年前 (2018/08/14 13:19), 編輯推噓6(821)
留言11則, 10人參與, 7年前最新討論串2/2 (看更多)
※ 引述《kbgarnett (Ice)》之銘言: : 餓死抬頭 : 剛一個數學問題想了很久想不出來 : 總數13204 : 如果用399、888、1299、2999 : 在總計26次裡 : 可以各幾次總加成13204嗎 : 謝謝 : ----- : Sent from JPTT on my iPhone 用 python 搭配 numpy 暴力解一下: import numpy as np import math from itertools import product TARGET = 13204 PARTS = [399, 888, 1299, 2999] upper_bounds = [math.ceil(TARGET / part) for part in PARTS] candidates = [np.arange(upper_bound) for upper_bound in upper_bounds] cartesian_products = np.array([prod for prod in product(*candidates)]) inner_products = np.inner(PARTS, cartesian_products) indices = np.argwhere(inner_products == TARGET)[:, 0] results = cartesian_products[indices] print(TARGET, end='') for result in results: print('\n= ', end='') for i in range(len(PARTS)): print(' +' if i > 0 else '', PARTS[i], '*', result[i], end='') 靠北根本無解啊 -- http://i.imgur.com/OyDCwTJ.jpg
by 系列圖簽名檔產生器: https://github.com/gocreating/signature-image-generator -- ※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 140.113.236.60 ※ 文章網址: https://www.ptt.cc/bbs/Gossiping/M.1534223968.A.FEB.html

08/14 13:19, 7年前 , 1F
樓下 懂嗎
08/14 13:19, 1F

08/14 13:20, 7年前 , 2F
ㄅ欠 不懂
08/14 13:20, 2F

08/14 13:20, 7年前 , 3F
沒關係 我也不懂
08/14 13:20, 3F

08/14 13:20, 7年前 , 4F
五樓文組看不懂
08/14 13:20, 4F

08/14 13:21, 7年前 , 5F
快推免得別人以為我不…算了
08/14 13:21, 5F

08/14 13:24, 7年前 , 6F
這個你也要用np解......
08/14 13:24, 6F

08/14 13:32, 7年前 , 7F
殺雞牛刀
08/14 13:32, 7F

08/14 13:43, 7年前 , 8F
08/14 13:43, 8F

08/14 13:45, 7年前 , 9F
明明一個簡單遞迴就能完成…
08/14 13:45, 9F

08/14 14:10, 7年前 , 10F
python就是潮
08/14 14:10, 10F

08/14 14:42, 7年前 , 11F
大砲打蚊子
08/14 14:42, 11F
文章代碼(AID): #1RScPW_h (Gossiping)
文章代碼(AID): #1RScPW_h (Gossiping)