-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbasic.cpp
More file actions
38 lines (33 loc) · 692 Bytes
/
basic.cpp
File metadata and controls
38 lines (33 loc) · 692 Bytes
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
#include <iostream>
#include <set>
#include <math.h>
#include <list>
#include <vector>
#include <map>
#include <algorithm>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
int gcd(int a, int b)
{
// greatest common divisor
int la = max(a, b);
int sm = min(a, b);
if (la % sm == 0)
return sm;
else
return gcd(sm, la - sm);
}
int lcm(int a, int b)
{
// least common multiple
return a * b / gcd(a, b);
}
bool findCharInString(string str, char c)
{
// if c not in str, str.find(c) return string::npos
return str.find(c) != string::npos;
}
// string S
// length S.length()
// map<string, int> mp;
// loop for (auto x : mp)