数字运算,判断一个数是否接近素数 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
一、RSA基本原理 对明文分组M和密文分组C,加密与解密过程如下: C = POW (M , e) mod n M = POW(C , d) mod n = POW(POW( M ,e), d) mod n=POW( M,e*d) 其中POW是指数函数,mod是求余数函数。 其中收发双方均已知n,发送放已知e,只有接受方已知d,因此公钥加密算法的公钥为 KU={ e , n},私钥为KR={d , n}。该算法要能用做公钥加密,必须满足下列条件: 1. 可以找到e ,d和n,使得对所有M<n ,POW(M ,e*d)=M mod n . 2. 对所有 M<n,计算POW (M , e)和POW(C , d)是比较容易的。 3. 由e 和n确定d是不可行的
上传时间: 2014-08-04
上传用户:sevenbestfei
源代码\用动态规划算法计算序列关系个数 用关系"<"和"="将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
这是一个学生成绩管理系统,其中“I”表示插入,“L”表示浏览,“Q”表示查询, “E”表示退出,“D”表示删除,“M”表示修改,"c"表示统计各分数段人数,"p"表示打印.
标签: 管理系统
上传时间: 2013-12-18
上传用户:kiklkook
上下文无关文法(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
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
这是一个学生成绩管理系统,其中“I”表示插入,“L”表示浏览,“Q”表示查询,“E”表示退出,“D”表示删除,“M”表示修改,"c"表示统计各分数段人数,"p"表示打印.(1)单独运行以上各功能,即在进入主菜单以后,点一功能键后关闭,再进入主菜单点别的功能键。如运行"cjgl"文件后,在出现的主界面中点“I”,可插入数据,插入完以后,关闭;在出现的主界面中点“M”,可修改数据,修改完以后关闭,用同样的方法可运行其它的功能。(2)连续运行部分的功能。应将文件"score.txt"放在相应的路径下.如在本程序中,需将该文件放在"c:\masm\score.txt"下.注:该文件的路径可从汇编源文件的"fname db "c:\masm\score.txt"""中查找.
标签: 管理系统
上传时间: 2014-12-05
上传用户:水中浮云
这是一个学生成绩管理系统,其中“I”表示插入,“L”表示浏览,“Q”表示查询, “E”表示退出,“D”表示删除,“M”表示修改,"c"表示统计各分数段人数,"p"表示打印.
标签: 管理系统
上传时间: 2014-01-24
上传用户:jjj0202
这是一个学生成绩管理系统,其中“I”表示插入,“L”表示浏览,“Q”表示查询, “E”表示退出,“D”表示删除,“M”表示修改,"c"表示统计各分数段人数,"p"表示打印. 本程序实现了:
标签: 管理系统
上传时间: 2017-01-28
上传用户:stvnash