数字运算,判断一个数是否接近素数 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
电力系统在台稳定计算式电力系统不正常运行方式的一种计算。它的任务是已知电力系统某一正常运行状态和受到某种扰动,计算电力系统所有发电机能否同步运行 1运行说明: 请输入初始功率S0,形如a+bi 请输入无限大系统母线电压V0 请输入系统等值电抗矩阵B 矩阵B有以下元素组成的行矩阵 1正常运行时的系统直轴等值电抗Xd 2故障运行时的系统直轴等值电抗X d 3故障切除后的系统直轴等值电抗 请输入惯性时间常数Tj 请输入时段数N 请输入哪个时段发生故障Ni 请输入每时段间隔的时间dt
上传时间: 2015-06-13
上传用户:it男一枚
我自己编写的字符串类,可以实现一些简单的功能,如赋值、加法、字符串比较、下边运算符重载等!
上传时间: 2013-12-23
上传用户:ynwbosss
声明一个一维数组,其长度为5,利用循环对数组元素进行赋值,然后再利用另一个循环逆序输出数组元素的内容。程序代码如下:
标签: 数组
上传时间: 2015-07-11
上传用户:CHINA526
1. PL/0 语言介绍 ●PL/0 程序设计语言是一个较简单的语言,它以赋值语句为基础,构造概念有顺序、条件和重复(循环)三种。PL/0 有子程序概念,包括过程定义(可以嵌套)与调用且有局部变量说明。PL/0语言编译程序采用以语法分析为核心、一遍扫描的编译方法。词法分析和代码生成作为独立的子程序供语法分析程序调用。语法分析的同时,提供了出错报告和出错恢复的功能。在源程序没有错误编译通过的情况下,调用类PCODE解释程序解释执行生成的类PCODE代码。 ●保留字(关键字):所谓保留字是指在Pascal语言中具有特定的含义。标准Pascal语言中的保留字一共有35个,Turbo Pascal语言一共有51个。下面是Pascal语言的保留字:AND,ARRAY,BEGIN,CASE,CONST,DIV,DO,DOWNTO,ELSE,END,FILE,FOR,FUNTION,GOTO,IF,IN,LABEL,MOD,NIL,NOT,OF,OR,PACKED,PROCEDURE,PROGRAM,RECORD,REPEAT,SET,THEN,TO,TYPE,UNTIL,VAR,WHILE,WITH,EXPORTS,SHR,STRING,ASM,OBJECT,UNIT,CONSTRUCTOR,IMPLEMENTATION,DESTRUCTOR,USES,INHERITED,INLINE,INTERFACE,LIBRARY,XOR,SHL
上传时间: 2015-07-17
上传用户:zm7516678
plo 清华版的第二章的那个!! 1. 基本内容(成绩范围:“中”、“及格”或“不及格”) 对PL/0作以下修改扩充: (1)增加单词:保留字 ELSE,FOR,TO, DOWNTO 运算符 +=,-=,++,-- 修改单词:不等号# 改为 <> 增加条件语句的ELSE子句 (2)扩充赋值运算:+= 和 -= (3)扩充语句(Pascal的FOR语句): ①FOR <变量>:=<表达式> TO <表达式> DO <语句> ②FOR <变量>:=<表达式> DOWNTO <表达式> DO <语句> 其中,语句①的循环变量的步长为1, 语句②的循环变量的步长为-1。 选做内容: (1)增加运算:++ 和 --。 (4)增加一维数组类型(可增加指令)
上传时间: 2014-01-10
上传用户:Breathe0125
编译原理课程设计报告对以下文法,采用算符优先分析算法,对G[S]所定义的赋值语句进行语法分析,并在语法分析过程中将所输入的扶植语句翻译为四元式。
上传时间: 2013-12-23
上传用户:362279997
1.这个计算器可用在离散数学的数理逻辑中,纯属工具,随意传播,由java语言实现,解压即可运行,需要按照java环境。可以去这里下载运行环境:http://www.skycn.com/soft/3116.html 2.这个计算器可以计算逻辑表达式的值、对应的真值表、主析取范式、主合取范式。 3.输入表达式时可以在表达式栏中输入,也可用相应的按钮输入,变元只能是PQRST。由于等价连接词无法识别,所以用等号代替,这也是一个无奈的选择。 4.计算前请选择变元个数(默认为3元)并对变元赋值。变元个数最高为5,基本能满足日常的计算。 5.计算器有自动检查表达式是否正确的功能,如果判断功能有误,麻烦您告诉我您的表达式。
上传时间: 2013-12-13
上传用户:txfyddz