摘要:
http://msdn.microsoft.com/en-us/library/windows/desktop/ms682079(v=vs.85).aspxEach console has an input buffer that contains a queue of input event records. When a console's window has the keyboard focus, a console formats each input event (such as a single keystroke, a movement of the mouse, or 阅读全文
摘要:
1.表示成和的形式:第k位的权值应该等于 后面 k - 1位所能表示的最大的数 + 1这样 能成单射,满射(1): 利用 等比数列: N 进制a(k) = nka(k) - 1 = (n - 1) * ( 1 - n k)⁄1 - n如2进制:k k-1 k-2 ... 3 2 1 0 第k位 2k 2k-1 2k-2 23 22 21 20 权值[0, 1] ................................................................ 系数(2) 利用 阶乘公式:k k-1 ... 阅读全文
摘要:
#include bool next_permutation(int *arr, int n){ if (n == 1 || n == 0) return false; int i; for (i = n - 2; i >= 0; --i) { if (arr[i] arr[i]) break; } int tmp = arr[i]; arr[i] = arr[j]; arr[j] = tmp; } int low = i + 1; int high = n - 1; for... 阅读全文
摘要:
今早起来写了个N皇后#include #define abs(i) ((i) < 0 ? -(i) : (i))const int N = 8;int board[N] = {-1};bool ok(int row){ if (row == 0) return true; for (int i = 0; i < row; ++i) { if (((row - i) == abs(board[row] - board[i])) || board[row] - board[i] == 0 ) return false; ... 阅读全文