數(shù)字運(yùn)算,判斷一個(gè)數(shù)是否接近素?cái)?shù) A Niven number is a number such that the sum of its digits divides itself. For example, 111 is a Niven number because the sum of its digits is 3, which divides 111. We can also specify a number in another base b, and a number in base b is a Niven number if the sum of its digits divides its value. Given b (2 <= b <= 10) and a number in base b, determine whether it is a Niven number or not. Input Each line of input contains the base b, followed by a string of digits representing a positive integer in that base. There are no leading zeroes. The input is terminated by a line consisting of 0 alone. Output For each case, print "yes" on a line if the given number is a Niven number, and "no" otherwise. Sample Input 10 111 2 110 10 123 6 1000 8 2314 0 Sample Output yes yes no yes no
上傳時(shí)間: 2015-05-21
上傳用戶:daguda
輸入:一段任意的程序(字符串)。 輸出:相應(yīng)的屬性字序列。 要求:⒈不處理說明部分,但屬性字的符號(hào)類除了編碼外,應(yīng)包含更多的信息(如運(yùn)算符的優(yōu)先級(jí)等); ⒉小子集中包含的符號(hào)類應(yīng)有典型性,且盡可能豐富; ⒊為了使用方便和便于閱讀,應(yīng)有幫助信息,說明可以有哪些符號(hào),屬性字的結(jié)構(gòu)如何等; 說明;⒈為了直觀起見,屬性字中的符號(hào)值可以是符號(hào)本身,而不是助憶符; ⒉符號(hào)的種類以及符號(hào)的編碼是事先規(guī)定的,可考慮擴(kuò)充的可能性。
上傳時(shí)間: 2014-01-17
上傳用戶:fhzm5658
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
標(biāo)簽: government streamline important alphabet
上傳時(shí)間: 2015-06-09
上傳用戶:weixiao99
根據(jù)給定的程序進(jìn)行調(diào)試,讀懂每個(gè)句子的具體含義,打印輸出結(jié)果。對(duì)原有程序進(jìn)行修改,打印輸出結(jié)果。并進(jìn)行說明更改了哪部分,與原程序有哪些不同。
上傳時(shí)間: 2015-06-16
上傳用戶:banyou
十年前,微軟帝國(guó)的締造者比爾-蓋茨(Bill Gates)曾撰寫過一本在當(dāng)時(shí)轟動(dòng)一時(shí)的書——《未來之路》,他在這本276頁(yè)的書中預(yù)測(cè)了微軟乃至整個(gè)科技產(chǎn)業(yè)未來的走勢(shì)。蓋茨在書中寫道:“雖然現(xiàn)在看來這些預(yù)測(cè)不太可能實(shí)現(xiàn),甚至有些荒謬,但是我保證這是本嚴(yán)肅的書,而決不是戲言。十年后我的觀點(diǎn)將會(huì)得到證實(shí)。”一轉(zhuǎn)眼十年過去了,現(xiàn)在讓我們回顧一下蓋茨的書中到底預(yù)測(cè)了些什么,又有哪些已經(jīng)成為了現(xiàn)實(shí)。
標(biāo)簽:
上傳時(shí)間: 2013-12-23
上傳用戶:541657925
上下文無關(guān)文法(Context-Free Grammar, CFG)是一個(gè)4元組G=(V, T, S, P),其中,V和T是不相交的有限集,S∈V,P是一組有限的產(chǎn)生式規(guī)則集,形如A→α,其中A∈V,且α∈(V∪T)*。V的元素稱為非終結(jié)符,T的元素稱為終結(jié)符,S是一個(gè)特殊的非終結(jié)符,稱為文法開始符。 設(shè)G=(V, T, S, P)是一個(gè)CFG,則G產(chǎn)生的語言是所有可由G產(chǎn)生的字符串組成的集合,即L(G)={x∈T* | Sx}。一個(gè)語言L是上下文無關(guān)語言(Context-Free Language, CFL),當(dāng)且僅當(dāng)存在一個(gè)CFG G,使得L=L(G)。 *⇒ 例如,設(shè)文法G:S→AB A→aA|a B→bB|b 則L(G)={a^nb^m | n,m>=1} 其中非終結(jié)符都是大寫字母,開始符都是S,終結(jié)符都是小寫字母。
標(biāo)簽: Context-Free Grammar CFG
上傳時(shí)間: 2013-12-10
上傳用戶:gaojiao1999
一:需求分析 1. 問題描述 魔王總是使用自己的一種非常精練而抽象的語言講話,沒人能聽懂,但他的語言是可逐步解釋成人能聽懂的語言,因?yàn)樗恼Z言是由以下兩種形式的規(guī)則由人的語言逐步抽象上去的: ----------------------------------------------------------- (1) a---> (B1)(B2)....(Bm) (2)[(op1)(p2)...(pn)]---->[o(pn)][o(p(n-1))].....[o(p1)o] ----------------------------------------------------------- 在這兩種形式中,從左到右均表示解釋.試寫一個(gè)魔王語言的解釋系統(tǒng),把 他的話解釋成人能聽得懂的話. 2. 基本要求: 用下述兩條具體規(guī)則和上述規(guī)則形式(2)實(shí)現(xiàn).設(shè)大寫字母表示魔王語言的詞匯 小寫字母表示人的語言的詞匯 希臘字母表示可以用大寫字母或小寫字母代換的變量.魔王語言可含人的詞匯. (1) B --> tAdA (2) A --> sae 3. 測(cè)試數(shù)據(jù): B(ehnxgz)B 解釋成 tsaedsaeezegexenehetsaedsae若將小寫字母與漢字建立下表所示的對(duì)應(yīng)關(guān)系,則魔王說的話是:"天上一只鵝地上一只鵝鵝追鵝趕鵝下鵝蛋鵝恨鵝天上一只鵝地上一只鵝". | t | d | s | a | e | z | g | x | n | h | | 天 | 地 | 上 | 一只| 鵝 | 追 | 趕 | 下 | 蛋 | 恨 |
上傳時(shí)間: 2014-12-02
上傳用戶:jkhjkh1982
這個(gè)是sap講義,幫助大家認(rèn)識(shí)sap有哪些方面業(yè)務(wù)知識(shí)。
上傳時(shí)間: 2015-11-24
上傳用戶:cc1015285075
80386處理器是Intel公司80x86發(fā)展史上的里程碑,它不但兼容先前的8086/8088,80186,80286處理器,而且也為后來的486,Pentium(586),Pentium Pro(686)的發(fā)展打下了堅(jiān)實(shí)的基礎(chǔ),對(duì)于我們程序員來講更重要的是:我們關(guān)心80386在指令上到底有哪些擴(kuò)展呢?80386有哪些尋址方式呢?毫無疑問,它不但兼容了8086的所有指令,而且還對(duì)它們進(jìn)行增強(qiáng).
標(biāo)簽: 80386 Intel 80x86 處理器
上傳時(shí)間: 2015-12-31
上傳用戶:ayfeixiao
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.
標(biāo)簽: represented integers group items
上傳時(shí)間: 2016-01-17
上傳用戶:jeffery
蟲蟲下載站版權(quán)所有 京ICP備2021023401號(hào)-1