![](https://img-blog.csdnimg.cn/20201014180756928.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
理论性总结
文章平均质量分 82
林伏案
妖蛾子良多的范老爷
展开
-
常见的位运算
交换两个元素的值:a ^= b ^= a ^= b; k位取反:a = ~(~a^(a << k)); 统计一个二进制数中1的数量: int bitCnt(int n) { int cnt = 0; while(n) { ++cnt; n &= n - 1; } return cnt; }4.右移一位相当于除以 2 ,右移 n 位相当于原创 2016-04-19 09:04:52 · 295 阅读 · 0 评论 -
numerical
#include <iostream> #include <cstdio> #include <cstring> #include <algorithm> #include <cmath>using namespace std; const int maxn = 100; const int linit = 1000;double coe_array[maxn][maxn + 1], l[maxn]原创 2016-05-16 23:32:32 · 450 阅读 · 0 评论 -
枚举排列
/* 利用STL中的next_permutation枚举排列 */ #include <iostream> #include <algorithm>using namespace std;int main() { int n, s[10]; int cnt = 0; //计数共有多少种排列组合 cin >> n; for(int i = 0; i < n; i++原创 2016-05-07 19:47:07 · 231 阅读 · 0 评论 -
二进制枚举法枚举子集
A&B,A|B和A^B分别对应集合的交,并和对称差。 空集为0,全集all_bits = (1 << n) - 1 A的补集为all_bits ^ A 下面是有关代码: #include <iostream> #include <cstdio>using namespace std; int main() { int n; cin >> n; for(int i = 0; i原创 2016-05-07 19:55:57 · 379 阅读 · 0 评论 -
n皇后问题
#include #include using namespace std; int n, vis[3][1000], cnt = 0; int place(int cur) { //尝试在当前行放置一个数 if(cur == n) cnt++; //表明已经产生了一种解法 else { for(int i = 0; i < n; i++) {原创 2016-05-07 20:00:29 · 191 阅读 · 0 评论 -
背包九讲的总结笔记(一)
基础的01背包 题目: 有N件物品和一个容量为V的背包。放入第i件物品耗费的空间是Ci,得到的价值是Wi。求解将哪些物品装入背包可使价值总和最大。 基本思路: F[i,v]表示前i件物品恰放入一个容量为v的背包可以获得的最大价值。则其状态转移方程便是:F[i,v]=max{F[i−1,v],F[i−1,v−Ci]+Wi} 然后根据这个方程便可以写出伪代码,具体代码最好根据不同题目原创 2016-09-02 09:45:49 · 688 阅读 · 0 评论 -
汇编代码存档
程序设计项目一 data segment dw data ends end 要求: 只在定义的数据段'?'中加入相关的内容,使得上面的程序可以在屏幕中间显示一个绿色的字符'A'。 data segment dw 00b8h, 8eb8h, 0bec0h, 0140h, 02b4h, 61b0h, 8926h, 0b804h, 4c00h, 21cdh data end原创 2017-01-24 12:47:11 · 664 阅读 · 0 评论