數字運算,判斷一個數是否接近素數
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
Programming C#, the top selling book on Microsoft s high-performance C# programming language, is now in its fourth edition. Aimed at experienced programmers and web developers, this comprehensive guide focuses on the features and programming patterns that are new to C#, and fundamental to the programming of web services and web applications on Microsoft s .NET platform.
/*
* EULER S ALGORITHM 5.1
*
* TO APPROXIMATE THE SOLUTION OF THE INITIAL VALUE PROBLEM:
* Y = F(T,Y), A<=T<=B, Y(A) = ALPHA,
* AT N+1 EQUALLY SPACED POINTS IN THE INTERVAL [A,B].
*
* INPUT: ENDPOINTS A,B INITIAL CONDITION ALPHA INTEGER N.
*
* OUTPUT: APPROXIMATION W TO Y AT THE (N+1) VALUES OF T.
*/
Implemented BFS, DFS and A*
To compile this project, use the following command:
g++ -o search main.cpp
Then you can run it:
./search
The input is loaded from a input file in.txt
Here is the format of the input file:
The first line of the input file shoud contain two chars indicate the source and destination city for breadth first and depth first algorithm.
The second line of input file shoud be an integer m indicate the number of connections for the map.
Following m lines describe the map, each line represents to one connection in this form: dist city1 city2, which means there is a connection between city1 and city2 with the distance dist.
The following input are for A*
The following line contains two chars indicate the source and destination city for A* algorithm.
Then there is an integer h indicate the number of heuristic.
The following h lines is in the form: city dist which means the straight-line distance from the city to B is dist.
VC技術內幕第五版(英文)The 6.0 release of Visual C++ shows Microsoft s continued focus on Internet technologies and COM, which are key components of the new Windows Distributed interNet Application Architecture (DNA). In addition to supporting these platform initiatives, Visual C++ 6.0 also adds an amazing number of productivity-boosting features such as Edit And Continue, IntelliSense, AutoComplete, and code tips. These features take Visual C++ to a new level. We have tried to make sure that this book keeps you up to speed on the latest technologies being introduced into Visual C++.
The MATLAB coding style, project options and synthesis directives can have a significant effect on the final results. Knowledge about how a particular algorithm should be implemented in hardware can be reflected in the MATLAB code to improve the results. In doing so, the MATLAB loses a bit of its abstraction but the lower-level MATLAB will infer the desired architecture into the device.
HDOJ 1047
One of the first users of BIT s new supercomputer was Chip Diller. He extended his exploration of powers of 3 to go from 0 to 333 and he explored taking various sums of those numbers.
``This supercomputer is great, remarked Chip. ``I only wish Timothy were here to see these results. (Chip moved to a new apartment, once one became available on the third floor of the Lemon Sky apartments on Third Street.)
java 數據庫 功能強大 效率高
SmallSQL Database is a free DBMS library for the Java(tm) platform. It runs
on the Java 2 Platform (JDK 1.4 or later) and implements the JDBC 3.0 API.
SmallSQL Database is licensed under the terms of the GNU Lesser General
Public Licence (LGPL). A copy of the licence is included in the
distribution.
Please note that SmallSQL Database is distributed WITHOUT ANY WARRANTY
without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
PARTICULAR PURPOSE. Please refer to the licence for details.