摘要:
思路 这题的思路很简单,没在该在的位置上,就要去按位与。关于是否有解,由于它是 0∼n−10∼n-10∼n−1 的排列,所以一定可以排序,也一定有解。 code: #include<bits/stdc++.h> using namespace std; int a[200005], cnt; int 阅读全文
摘要:
组合数,可用 dfs 解决,思路就是先选一个数,并标记,后面依次寻找未标记的数,构造成功后输出。 #include<bits/stdc++.h> using namespace std; int n, r; int a[100000];//存放选出的数 bool b[100000];//标记 voi 阅读全文
摘要:
龟速乘模板。 问:啥是龟速乘? 答:当数过大时,两数相乘还没模就爆 long long 了,这显然不好 (除非你爱写高精)。 原理类似快速幂,详见this blog。 最后记得开 long long。 #include<bits/stdc++.h> using namespace std; long 阅读全文