-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathACVR.cpp
More file actions
111 lines (89 loc) · 2.08 KB
/
ACVR.cpp
File metadata and controls
111 lines (89 loc) · 2.08 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
#include "ACVR.h"
void to_upper(string & str) {
for (auto & c: str) c = toupper(c);
}
void to_valid(string & str) {
for (int i = 0; i < str.length(); i++) {
if ((str[i] < 'A' or str[i] > 'Z') and (str[i] < 'a' or str[i] > 'z')) {
str.erase(i, 1);
}
}
}
unsigned long gcd_recursive(unsigned a, unsigned b) {
if (b)
return gcd_recursive(b, a % b);
else
return a;
}
bool isPrime(int n) {
if (n <= 1) { return false; }
for (int i = 2; i <= n / 2; i++) {
if (n % i == 0) { return false; }
}
return true;
}
vector<string> split(string str, string delimiter)
{
vector<string> v;
if (!str.empty()) {
int start = 0;
do {
int index = str.find(delimiter, start);
if (index == string::npos) {
break;
}
int length = index - start;
v.push_back(str.substr(start, length));
start += (length + delimiter.size());
} while (true);
v.push_back(str.substr(start));
}
return v;
}
//modPow
int modExp(int a, int b, int n) {
long long x=1, y=a;
while (b > 0) {
if (b%2 == 1) {
x = (x*y) % n;
}
y = (y*y) % n;
b /= 2;
}
return x % n;
}
bool in(char sym, string Alphabet) {
for (char i : Alphabet) {
if (i == sym) {
return true;
}
}
return false;
}
string input(string Alphabet, int n) {
string buffer;
char sym;
int c = 0;
do {
sym = (char) getch();
if (sym == VK_BACK and !buffer.empty()) {
putch(VK_BACK);
putch(VK_SPACE);
putch(VK_BACK);
buffer.pop_back();
c--;
}
else if (in(sym, Alphabet) and c != n) {
c++;
buffer += sym;
putch(sym);
}
} while (sym != VK_RETURN);
return buffer;
}
int int_check(string str) {
for (int i = 0; i < str.length(); i++) {
if (str[i] == ' ' || isdigit(str[i]) == 0) { return 0; }
}
return 1;
}