數字運算,判斷一個數是否接近素數
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
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
什么是 VBScript?
Microsoft Visual Basic Scripting Edition 是程序開發語言 Visual Basic 家族的最新成員,它將靈活的腳本應用于更廣泛的領域,包括 Microsoft Internet Explorer 中的 Web 客戶機腳本和 Microsoft Internet Information Service 中的 Web 服務器腳本。
ActiveX腳本可用在 Microsoft(R) Internet Explorer 和 Microsoft(R) Internet Information Service 中。
其他應用程序和瀏覽器中的 VBScript
作為開發者,您可以在您的產品中免費使用 VBScript 源實現程序。Microsoft 為 32 位 Windows(R) API、16 位 Windows API 和 Macintosh(R) 提供 VBscript 的二進制實現程序。VBScript 與 World Wide Web 瀏覽器集成在一起。VBScript 和 ActiveX腳本也可以在其他應用程序中作為普通腳本語言使用。