赛前写一下
GCD
int gcd(int a, int b)
{
return b ? gcd(b, a % b) : a;
}
LCM
int lcm(int a, int b)
{
return a / gcd(a, b) * b;
}
位运算
int lowbit(int x)
{
return x & -x;
}
int main()
{
cin >> x;
int res = 0;
while (x)
{
x -= lowbit(x);
res ++;
}
}
线性筛
void get_primes()
{
for (int i = 2;i <= n; i ++)
{
if (!st[i])
primes[cnt ++] = i;
for (int j = 0; primes[j] <= n / i; j ++)
{
st[primes[j] * i] = true;
if (i % primes[j] == 0) break;
}
}
}