数字运算,判断一个数是否接近素数 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
上传时间: 2015-05-21
上传用户:daguda
源代码\用动态规划算法计算序列关系个数 用关系"<"和"="将3个数a,b,c依次序排列时,有13种不同的序列关系: a=b=c,a=b<c,a<b=v,a<b<c,a<c<b a=c<b,b<a=c,b<a<c,b<c<a,b=c<a c<a=b,c<a<b,c<b<a 若要将n个数依序列,设计一个动态规划算法,计算出有多少种不同的序列关系, 要求算法只占用O(n),只耗时O(n*n).
上传时间: 2013-12-26
上传用户:siguazgb
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
上下文无关文法(Context-Free Grammar, CFG)是一个4元组G=(V, T, S, P),其中,V和T是不相交的有限集,S∈V,P是一组有限的产生式规则集,形如A→α,其中A∈V,且α∈(V∪T)*。V的元素称为非终结符,T的元素称为终结符,S是一个特殊的非终结符,称为文法开始符。 设G=(V, T, S, P)是一个CFG,则G产生的语言是所有可由G产生的字符串组成的集合,即L(G)={x∈T* | Sx}。一个语言L是上下文无关语言(Context-Free Language, CFL),当且仅当存在一个CFG G,使得L=L(G)。 *⇒ 例如,设文法G:S→AB A→aA|a B→bB|b 则L(G)={a^nb^m | n,m>=1} 其中非终结符都是大写字母,开始符都是S,终结符都是小写字母。
标签: Context-Free Grammar CFG
上传时间: 2013-12-10
上传用户:gaojiao1999
:面向对象软件测试是面向对象软件开发的重要一环,是保证软件质量提高软件可靠性的关键。结合传统软件测试 的方法和技术,并针对面向对象软件所具有的特征,将面向对象软件测试层次划分为3层:类测试、类簇测斌和系统测试, 讨论了面向对象软件测试的测试方法和解决方案,并以销售系统为例,给出了相应层次的具体测试策略。
上传时间: 2013-12-17
上传用户:84425894
介绍利用VB6串行通信编程的方法,对采用了RS-232接口的仪器进行串行通信的计算机测控软件开发,以及实现仪器功能和指标的验收。
上传时间: 2015-12-03
上传用户:as275944189
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
The XML Toolbox converts MATLAB data types (such as double, char, struct, complex, sparse, logical) of any level of nesting to XML format and vice versa. For example, >> project.name = MyProject >> project.id = 1234 >> project.param.a = 3.1415 >> project.param.b = 42 becomes with str=xml_format(project, off ) "<project> <name>MyProject</name> <id>1234</id> <param> <a>3.1415</a> <b>42</b> </param> </project>" On the other hand, if an XML string XStr is given, this can be converted easily to a MATLAB data type or structure V with the command V=xml_parse(XStr).
标签: converts Toolbox complex logical
上传时间: 2016-02-12
上传用户:a673761058
传统的高校教学设备跟不上新技术的飞速发展,使得设备淘汰加快,而要重新购买新的 技术设备,使得资金利用率降低。为了提高设备利用率,我公司在积累前几代产品的成功经验基础上,研制了一款多功能开放性实验仪——CUNSI-DSP 综合实验仪,学校和学生可根据当前技术方向自行设计模块。使之跟随日新月异的技术发展。完全适合电子信息、信号处理、自动化、通信工程、物理、测控、软件及图象处理等相关专业的实验及创新研发。同时本产品也是大学生电子设计竞赛的最佳开发平台。
上传时间: 2016-05-08
上传用户:stvnash
摘要:分析了影响同步电动机矢m:控制电流控制环动态特性的主要因索.指出同步电动机反电动势是 其中最重要的{一扰因索针对通常采用的F I(比例一积分)电流调 y器因下作频带的限制无法在较高转速时 抑制反电动势的影响.提出了前馈补偿和变电流环增益的设计方法.少}应用于基于数-f_信写处理器的矢m:控 制系统给出了系统结构及软硬件设计方案实验结果表明.该系统硬件简的一控制精l夏高.动态}h I能良好(.caj)
上传时间: 2016-05-22
上传用户:奇奇奔奔