The government of a small but important country has decided that the alphabet needs to be streamlined and reordered. Uppercase letters will be eliminated. They will issue a royal decree in the form of a String of B and A characters. The first character in the decree specifies whether a must come ( B )Before b in the new alphabet or ( A )After b . The second character determines the relative placement of b and c , etc. So, for example, "BAA" means that a must come Before b , b must come After c , and c must come After d . Any letters beyond these requirements are to be excluded, so if the decree specifies k comparisons then the new alphabet will contain the first k+1 lowercase letters of the current alphabet. Create a class Alphabet that contains the method choices that takes the decree as input and returns the number of possible new alphabets that conform to the decree. If more than 1,000,000,000 are possible, return -1. Definition
標簽: government streamline important alphabet
上傳時間: 2015-06-09
上傳用戶:weixiao99
一:需求分析 1. 問題描述 魔王總是使用自己的一種非常精練而抽象的語言講話,沒人能聽懂,但他的語言是可逐步解釋成人能聽懂的語言,因為他的語言是由以下兩種形式的規則由人的語言逐步抽象上去的: ----------------------------------------------------------- (1) a---> (B1)(B2)....(Bm) (2)[(op1)(p2)...(pn)]---->[o(pn)][o(p(n-1))].....[o(p1)o] ----------------------------------------------------------- 在這兩種形式中,從左到右均表示解釋.試寫一個魔王語言的解釋系統,把 他的話解釋成人能聽得懂的話. 2. 基本要求: 用下述兩條具體規則和上述規則形式(2)實現.設大寫字母表示魔王語言的詞匯 小寫字母表示人的語言的詞匯 希臘字母表示可以用大寫字母或小寫字母代換的變量.魔王語言可含人的詞匯. (1) B --> tAdA (2) A --> sae 3. 測試數據: B(ehnxgz)B 解釋成 tsaedsaeezegexenehetsaedsae若將小寫字母與漢字建立下表所示的對應關系,則魔王說的話是:"天上一只鵝地上一只鵝鵝追鵝趕鵝下鵝蛋鵝恨鵝天上一只鵝地上一只鵝". | t | d | s | a | e | z | g | x | n | h | | 天 | 地 | 上 | 一只| 鵝 | 追 | 趕 | 下 | 蛋 | 恨 |
上傳時間: 2014-12-02
上傳用戶:jkhjkh1982
We have a group of N items (represented by integers from 1 to N), and we know that there is some total order defined for these items. You may assume that no two elements will be equal (for all a, b: a<b or b<a). However, it is expensive to compare two items. Your task is to make a number of comparisons, and then output the sorted order. The cost of determining if a < b is given by the bth integer of element a of costs (space delimited), which is the same as the ath integer of element b. Naturally, you will be judged on the total cost of the comparisons you make before outputting the sorted order. If your order is incorrect, you will receive a 0. Otherwise, your score will be opt/cost, where opt is the best cost anyone has achieved and cost is the total cost of the comparisons you make (so your score for a test case will be between 0 and 1). Your score for the problem will simply be the sum of your scores for the individual test cases.
標簽: represented integers group items
上傳時間: 2016-01-17
上傳用戶:jeffery
漢諾塔!!! Simulate the movement of the Towers of Hanoi puzzle Bonus is possible for using animation eg. if n = 2 A→B A→C B→C if n = 3 A→C A→B C→B A→C B→A B→C A→C
標簽: the animation Simulate movement
上傳時間: 2017-02-11
上傳用戶:waizhang
獲取計算機IP地址等網絡參數 UDP聊天程序 TCP聊天程序 瀏覽器的實現
標簽: 獲取計算機的名稱和IP地址 基本C/S模式的通信實驗
上傳時間: 2015-04-12
上傳用戶:scnbyh
NFS服務器實現文件共享
上傳時間: 2015-05-13
上傳用戶:yangkang1192
Use fft to analyse signal by plotting the original signal and its spectrum.
標簽: matlab fft
上傳時間: 2015-11-23
上傳用戶:石灰巖123
一、地址映射與數據傳輸 二、PCI9054的基本知識 三、PCI9054的寄存器之間的關系
標簽: PCI 總線學習筆記
上傳時間: 2016-02-15
上傳用戶:4722656
實驗十 子程序結構設計實驗
上傳時間: 2016-05-11
上傳用戶:txzdll
電力工程電纜設計規范 GB 50217-2007 3 電纜型式與截面選擇 3.1 電纜導體材質 3.2 電力電纜芯數 3.3 電纜絕緣水平 3.4 電纜絕緣類型 3.5 電纜護層類型 3.6 控制電纜及其金屬屏蔽 3.7 電力電纜導體截面 4 電纜附件的選擇與配置 4.1 一般規定 4.2 自容式充油電纜的供油系統 5 電纜敷設 5.1 一般規定 5.2敷設方式選擇 5.3地下直埋敷設 5.4保護管敷設 5.5電纜構筑物敷設 5.6其他公用設施中敷設 5.7水下敷設 6電纜的支持與固定 6.1 一般規定 6.2 電纜支架和橋架 7 電纜防火與阻止延燃 附錄A 常用電力電纜導體的最高允許溫度 附錄B 10kV及以下電力電纜經濟電流截面選用方法 附錄C 10kV及以下常用電力電纜允許100%持續載流量 附錄D 敷設條件不同時電纜允許持續載流量的校正系數 附錄E 按短路熱穩定條件計算電纜導體允許最小截面的方法
上傳時間: 2016-05-31
上傳用戶:fffvvv