int find(int x)
{
if(p[x] != x) p[x] = find(p[x]);
return p[x];
}
priority_queue<int, vector<int>, greater<int>>
sort(a, a + n, greater<int>())
int primes[N], cnt;
bool st[N];
void get_primes(int n)
{
for (int i = 2; i <= n; i ++ )
{
if(st[i] == false) primes[cnt++] = i;
for (int j = 0; primse[j] <= n/i; j ++ )
{
st[primes[j] * i] = true;
if(i % primes[j] == 0) break;
}
}
}
vector<int> div(vector<int> &A, int B, int r)
{
vector<int> C;
for (int i = 0; i < A.size(); i ++ )
{
r = r * 10 +A[i];
C.push_back(r/B);
r%=B;
}
reverse(C.begin(), C.end());
while(C.size() > 1 && C.back()==0) C.pop();
return C;
}
bool check(int date)
{
if(m<=0 || m>12) return false;
if(d<=0 || m!=2 && d>months[m]) return false;
if(m==2)
{
if(y%4==0 && y%100!=0 || y%400==0)
months[2] = 29;
if(d>months[m])
return false;
}
return true;
}
void C()
{
for (int i = 0; i < N; i ++ )
for (int j = 0; j <= i; j ++ )
if(j==0) C[i][j] = 1;
else C[i][j] = C[i - 1][j - 1] + C[i - 1][j];
}
void primes()
{
for (int i = 2; i < n/i; i ++ )
{
if(n%i==0)
{
int cnt = 0;
while(n%i==0)
{
n/=i;
cnt++;
}
printf("%d %d",i, cnt);
}
}
if(n>1) printf("%d %d",n, 1);
}
int e[N], ne[N], idx, h[N];
memset(h, -1, sizeof h);
void add(int a, int b)
{
e[idx] = b;
ne[idx] = h[a];
h[a] = idx;
idx ++;
}
void dfs(int u)
{
for(int i = h[u]; i != -1;i = ne[i])
{
int j = e[i];
if(st[j] == false)
{
dfs(j);
}
}
}
void maxv()
{
for (int i = 1; i <= n; i ++ )
{
f[i] = 1;
for (int j = 1; j < i; j ++ )
{
if(a[j] < a[i])
f[i] = max(f[i], f[j] + 1);
}
}
}
void maxv()
{
int n, m;//n为短串, m为长串
for (int i = 1; i <= n; i ++ )
{
for (int j = 1; j <= m; j ++ )
{
f[i][j] = max(f[i - 1][j], f[i][j - 1]);
if(s[i] == s[j])
f[i][j] = f[i - 1][j - 1] + 1;
}
}
}
void bag()
{
for (int i = 1; i <= n; i ++ )
for (int j = 0; j <= m; j ++ )
{
f[i][j] = f[i - 1][j];
if(j>=v[i])
f[i][j] = max(f[i][j], f[i - 1][j - v[i]] + w[i]);
}
}
void bag()
{
for (int i = 1; i <= n; i ++ )
for (int j = 0; j <= m; j ++ )
{
f[i][j] = f[i - 1][j];
if(j>=v[i])
f[i][j] = max(f[i][j], f[i][j - v[i]] + w[i]);
}
}
1~26对应a~z,
则要实现数字->字符, 可以
int num = 1;
cout << char(num + 'a' - 1);
则要实现字符->数字, 可以
char c = 'b';
cout << c - 'a' + 1;