OpeneR's Blog

For The Better Good

板子

板子

主模板

1
2
3
4
5
6
7
8
9
10
11
#include <bits/stdc++.h>
#define incf(i, a, b) for (int i = (a); i <= (b); i++)
#define decf(i, a, b) for (int i = (a); i >= (b); i--)
typedef long long ll;
using namespace std;
int cnt, cnt1, cnt2;
ll f[1000100], b;
inline int read(){int x=0,f=1;char ch=getchar();while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}while(ch>='0'&&ch<='9')x=x*10+ch-'0',ch=getchar();return x*f;}
int main(){

}

Tricks

###最大公约数

1
2
__gcd(a, b)
// 注意状态更新导致的第二次使用公约数函数会使得结果发生变化

高精度

1

读取个位数

1
2
3
4
5
6
7
while(f!=0){
dd = f % 10;//个位数也可以用
f = f /10;
if(dd==x){
k++;
}
}

冒泡排序

1
2
3
incf(i, 1, n - 1){incf(j, 1, n - i){if (r[j + 1] > r[j]){
swap(r[j], r[j + 1]);
}}}

快读

1
inline int read(){int x=0,f=1;char ch=getchar();while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}while(ch>='0'&&ch<='9')x=x*10+ch-'0',ch=getchar();return x*f;}
0%