Math 板


LINE

題目: https://imgur.com/a/oCMXgxw 不知道想法對不對 (a) Since if n has k digits, then the shortest-length formula must be <= k. -> shortest-length formula must be finite It's possible to enumerate the set of possible arithmetic formulas for n, with condition len(each formula) <= k -> the set is finite -> We can find the shortest-length formula in that set for a given n. -> It's possible to write a program to find the shortest formula for any n. (b) 先說hint部分 我不太知道要如何判斷 a program halts on given input -> halting problem -> unsolvable 多了within t steps 我應該可以用個counter去數有沒有超過t 所以應該做得出來 還有如果a program does not halt within t steps execution time就找不到minimum吧 那整個program cannot be done --



※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 61.224.180.237 (臺灣)
※ 文章網址: https://webptt.com/m.aspx?n=bbs/Math/M.1603792548.A.D7B.html
1F:→ hwanger : (a)(b)差不多就是你的想法 10/27 22:07
2F:→ hwanger : (a) 列出所有長度小於等於k的字串 篩出well-formed 10/27 22:08
3F:→ hwanger : formula 找會算出n的最短字串 10/27 22:08
4F:→ hwanger : (b) 先寫一個副程式Count(t,P) 判斷P 1.是否為一個 10/27 22:09
5F:→ hwanger : 合法程式碼 2.如果是合法程式碼 則是否能在t步內執 10/27 22:09
6F:→ hwanger : 行完畢 10/27 22:09
7F:→ hwanger : 接著考慮一段直接印出n的程式碼 [例如在c中 10/27 22:10
8F:→ hwanger : #include<stdio.h>(換行符號)int main(int argc, 10/27 22:10
9F:→ hwanger : char** argv){printf("%d",n);return 0;}] 10/27 22:10
10F:→ hwanger : 計算他的執行步數+符號個數 T 然後考慮所有符號個數 10/27 22:11
11F:→ hwanger : 在T內的字串P 再用Count(T,P)篩選 找會印出n的最短 10/27 22:11
12F:→ hwanger : 程式碼 >>>所以是可以找出"最短"的程式碼的 10/27 22:12
13F:→ hwanger : 上面是大致的想法 你可能還是依你們上課的嚴謹程度 10/27 22:15
14F:→ hwanger : 來完成細節 冏 10/27 22:15
15F:→ LiquidTLO : 了解,所以\sum_{i=0}^{\infty} Count(i,P)就能篩完 10/27 23:01
16F:→ LiquidTLO : 且保證minimum time/length 10/27 23:02
17F:→ hwanger : 不是很清楚你想表達什麼 不過跟(a)的k一樣 我們會有 10/27 23:04
18F:→ hwanger : 一個T的bound 10/27 23:04
19F:→ hwanger : 另外 在(b)中 還有一種case就是允許程式一開始就接 10/27 23:06
20F:→ LiquidTLO : 也對,因為length就是(a)的 10/27 23:06
21F:→ hwanger : 受一個外部參數 或中途輸入(scanf之類的) 但每接受 10/27 23:07
22F:→ hwanger : 一個字符就會耗去一次執行次數 所以可以input的字串 10/27 23:08
23F:→ hwanger : 長度也是有一個和T有關的上限N存在 所以也可以把所 10/27 23:10
24F:→ hwanger : 有長度N的字串放在Count的參數中考慮 Count(T,P,W) 10/27 23:12
25F:→ hwanger : 例如W="321\r44\r" 當程式要兩次讀入數字時 他就會 10/27 23:13
26F:→ hwanger : 先讀321 下次再讀44 而Count可以計算在某個W下 P的 10/27 23:15
27F:→ hwanger : 執行次數 10/27 23:15
28F:→ hwanger : 這邊表達的有點混亂 抱歉 不過因為你原本就有差不多 10/27 23:27
29F:→ hwanger : 的想法 我想傳達應該還是有傳達到 如果不清楚再問 10/27 23:28







like.gif 您可能會有興趣的文章
icon.png[問題/行為] 貓晚上進房間會不會有憋尿問題
icon.pngRe: [閒聊] 選了錯誤的女孩成為魔法少女 XDDDDDDDDDD
icon.png[正妹] 瑞典 一張
icon.png[心得] EMS高領長版毛衣.墨小樓MC1002
icon.png[分享] 丹龍隔熱紙GE55+33+22
icon.png[問題] 清洗洗衣機
icon.png[尋物] 窗台下的空間
icon.png[閒聊] 双極の女神1 木魔爵
icon.png[售車] 新竹 1997 march 1297cc 白色 四門
icon.png[討論] 能從照片感受到攝影者心情嗎
icon.png[狂賀] 賀賀賀賀 賀!島村卯月!總選舉NO.1
icon.png[難過] 羨慕白皮膚的女生
icon.png閱讀文章
icon.png[黑特]
icon.png[問題] SBK S1安裝於安全帽位置
icon.png[分享] 舊woo100絕版開箱!!
icon.pngRe: [無言] 關於小包衛生紙
icon.png[開箱] E5-2683V3 RX480Strix 快睿C1 簡單測試
icon.png[心得] 蒼の海賊龍 地獄 執行者16PT
icon.png[售車] 1999年Virage iO 1.8EXi
icon.png[心得] 挑戰33 LV10 獅子座pt solo
icon.png[閒聊] 手把手教你不被桶之新手主購教學
icon.png[分享] Civic Type R 量產版官方照無預警流出
icon.png[售車] Golf 4 2.0 銀色 自排
icon.png[出售] Graco提籃汽座(有底座)2000元誠可議
icon.png[問題] 請問補牙材質掉了還能再補嗎?(台中半年內
icon.png[問題] 44th 單曲 生寫竟然都給重複的啊啊!
icon.png[心得] 華南紅卡/icash 核卡
icon.png[問題] 拔牙矯正這樣正常嗎
icon.png[贈送] 老莫高業 初業 102年版
icon.png[情報] 三大行動支付 本季掀戰火
icon.png[寶寶] 博客來Amos水蠟筆5/1特價五折
icon.pngRe: [心得] 新鮮人一些面試分享
icon.png[心得] 蒼の海賊龍 地獄 麒麟25PT
icon.pngRe: [閒聊] (君の名は。雷慎入) 君名二創漫畫翻譯
icon.pngRe: [閒聊] OGN中場影片:失蹤人口局 (英文字幕)
icon.png[問題] 台灣大哥大4G訊號差
icon.png[出售] [全國]全新千尋侘草LED燈, 水草

請輸入看板名稱,例如:iOS站內搜尋

TOP