23 lines
393 B
C++
23 lines
393 B
C++
# include<string.h>
|
|
# include<string>
|
|
# include<cmath>
|
|
typedef long long int Lint;
|
|
|
|
extern "C" Lint hash(char* str) {
|
|
Lint m = std::pow(10,7) + 7;
|
|
int p = 97;
|
|
Lint total = 0;
|
|
|
|
for (int i=0; i<strlen(str); i++) {
|
|
total += (int(str[i]) - 32) * pow(p,i);
|
|
}
|
|
|
|
Lint result = total % m;
|
|
return result;
|
|
}
|
|
|
|
extern "C" Lint printc(char* str) {
|
|
int num = strlen(str);
|
|
return num;
|
|
}
|