-
數(shù)字運算,判斷一個數(shù)是否接近素數(shù)
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
標簽:
數(shù)字
運算
上傳時間:
2015-05-21
上傳用戶:daguda
-
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
-
CF+
and
CompactFlash
Specification
Revision 3.0
Use of this specification for product design requires an executed license agreement from the CompactFlash
Association.
標簽:
Specification
specification
CompactFlash
Revision
上傳時間:
2013-12-31
上傳用戶:Pzj
-
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
-
JaNet: Java Neural Network Toolkit
resume: A well documented toolkit for designing and training, and a java library for inclusion in third party programs.
description: jaNet package is a java neural network toolkit, which you can use to design, test, train and optimize an ideal Neural Network for your private application. You can then include your saved network in your program using the jaNet.backprop package. The consequent documentation is only in french for the moment, but an english translation is planned. The java source code is released under GPL, and can be compiled with JDK, Symantec Cafe or MS Visual J
標簽:
documented
designing
training
Network
上傳時間:
2016-04-15
上傳用戶:zhanditian
-
Implement the following integer methods:
a) Method celsius returns the Celsius equivalent of a Fahrenheit calculation
celsius = 5.0 / 9.0 * ( fahrenheit - 32 )
b) Method fahrenheit returns the Fahrenheit equivalent of a Celsius the calculation
fahrenheit = 9.0 / 5.0 * celsius + 32
c) Use the methods from parts (a) and (b) to write an application either to enter a Fahrenheit temperature and display the Celsius or to enter a Celsius temperature and display the Fahrenheit equivalent.
標簽:
equivalent
Implement
the
following
上傳時間:
2014-01-19
上傳用戶:jackgao
-
this document describes in details the freeman s chain code algorithm in regards to using for feature extraction in an OCR Application
it also describes all the necessary phases to develop an ocr
標簽:
describes
algorithm
document
details
上傳時間:
2014-01-17
上傳用戶:sy_jiadeyi
-
I would like to thank my advisor, Dr. A. Lynn Abbott, for helping me throughout
my research, Gary Fleming and the rest of the people at NASA Langley who provided all
the flight information and image sequences, and my parents who supported me in my
decision to enter graduate study. Also, thanks to Phichet Trisirisipal and Xiaojin Gong
for helping when I had computer vision questions, and Nathan Herald for his help
creating an illustration.
標簽:
A.
throughout
research
advisor
上傳時間:
2017-06-18
上傳用戶:maizezhen
-
實驗源代碼
//Warshall.cpp #include<stdio.h> void warshall(int k,int n) { int i , j, t; int temp[20][20]; for(int a=0;a<k;a++) { printf("請輸入矩陣第%d 行元素:",a); for(int b=0;b<n;b++) { scanf ("%d",&temp[a][b]); } } for(i=0;i<k;i++){ for( j=0;j<k;j++){ if(temp[ j][i]==1) { for(t=0;t<n;t++) { temp[ j][t]=temp[i][t]||temp[ j][t]; } } } } printf("可傳遞閉包關系矩陣是:\n"); for(i=0;i<k;i++) { for( j=0;j<n;j++) { printf("%d", temp[i][ j]); } printf("\n"); } } void main() { printf("利用 Warshall 算法求二元關系的可傳遞閉包\n"); void warshall(int,int); int k , n; printf("請輸入矩陣的行數(shù) i: "); scanf("%d",&k);
四川大學實驗報告 printf("請輸入矩陣的列數(shù) j: "); scanf("%d",&n); warshall(k,n); }
標簽:
warshall
離散
實驗
上傳時間:
2016-06-27
上傳用戶:梁雪文以
-
#include "iostream" using namespace std;
class Matrix
{
private:
double** A; //矩陣A
double *b; //向量b
public:
int size;
Matrix(int );
~Matrix();
friend double* Dooli(Matrix& );
void Input();
void Disp();
};
Matrix::Matrix(int x) {
size=x;
//為向量b分配空間并初始化為0
b=new double [x];
for(int j=0;j<x;j++)
b[j]=0;
//為向量A分配空間并初始化為0
A=new double* [x];
for(int i=0;i<x;i++)
A[i]=new double [x];
for(int m=0;m<x;m++)
for(int n=0;n<x;n++)
A[m][n]=0;
}
Matrix::~Matrix() {
cout<<"正在析構(gòu)中~~~~"<<endl;
delete b;
for(int i=0;i<size;i++)
delete A[i];
delete A;
}
void Matrix::Disp()
{
for(int i=0;i<size;i++)
{
for(int j=0;j<size;j++)
cout<<A[i][j]<<" ";
cout<<endl;
}
}
void Matrix::Input()
{
cout<<"請輸入A:"<<endl;
for(int i=0;i<size;i++)
for(int j=0;j<size;j++){
cout<<"第"<<i+1<<"行"<<"第"<<j+1<<"列:"<<endl;
cin>>A[i][j];
}
cout<<"請輸入b:"<<endl;
for(int j=0;j<size;j++){
cout<<"第"<<j+1<<"個:"<<endl;
cin>>b[j];
}
}
double* Dooli(Matrix& A) {
double *Xn=new double [A.size];
Matrix L(A.size),U(A.size);
//分別求得U,L的第一行與第一列
for(int i=0;i<A.size;i++)
U.A[0][i]=A.A[0][i];
for(int j=1;j<A.size;j++)
L.A[j][0]=A.A[j][0]/U.A[0][0];
//分別求得U,L的第r行,第r列
double temp1=0,temp2=0;
for(int r=1;r<A.size;r++){
//U
for(int i=r;i<A.size;i++){
for(int k=0;k<r-1;k++)
temp1=temp1+L.A[r][k]*U.A[k][i];
U.A[r][i]=A.A[r][i]-temp1;
}
//L
for(int i=r+1;i<A.size;i++){
for(int k=0;k<r-1;k++)
temp2=temp2+L.A[i][k]*U.A[k][r];
L.A[i][r]=(A.A[i][r]-temp2)/U.A[r][r];
}
}
cout<<"計算U得:"<<endl;
U.Disp();
cout<<"計算L的:"<<endl;
L.Disp();
double *Y=new double [A.size];
Y[0]=A.b[0];
for(int i=1;i<A.size;i++ ){
double temp3=0;
for(int k=0;k<i-1;k++)
temp3=temp3+L.A[i][k]*Y[k];
Y[i]=A.b[i]-temp3;
}
Xn[A.size-1]=Y[A.size-1]/U.A[A.size-1][A.size-1];
for(int i=A.size-1;i>=0;i--){
double temp4=0;
for(int k=i+1;k<A.size;k++)
temp4=temp4+U.A[i][k]*Xn[k];
Xn[i]=(Y[i]-temp4)/U.A[i][i];
}
return Xn;
}
int main()
{
Matrix B(4);
B.Input();
double *X;
X=Dooli(B);
cout<<"~~~~解得:"<<endl;
for(int i=0;i<B.size;i++)
cout<<"X["<<i<<"]:"<<X[i]<<" ";
cout<<endl<<"呵呵呵呵呵";
return 0;
}
標簽:
道理特分解法
上傳時間:
2018-05-20
上傳用戶:Aa123456789