原创 異或的性質

異或是一種基於二進制的位運算,用符號XOR或者 ^ 表示,其運算法則是對運算符兩側數的每一個二進制位,同值取0,異值取1。它與布爾運算的區別在於,當運算符兩側均爲1時,布爾運算的結果爲1,異或運算的結果爲0。 簡單理解就是不進位加

原创 Deranged Exams

Deranged Exams The first question on the Data Structures and Algorithms final exam has a list of N terms and a seco

原创 c++實現用戶密碼輸入界面

#include <stdio.h> #include <windows.h> #include <conio.h> #include <bits/stdc++.h> using namespace std; void gotox

原创 c++引用對比

#include <iostream> using namespace std; int main(){ int a = 1; double &b = a; cout << "a : " << a << "

原创 C語言中怎樣實現按ESC鍵就退出循環不按任何鍵就繼續循環?

#include <conio.h> #include <stdio.h> int main() { while(1) { if (_kbhit() && _getch()==0x1b)

原创 計蒜客MORE XOR

Given a sequence of nnn numbers a1a_1a1​, a2a_2a2​, ⋯\cdots⋯, ana_nan​ and three functions. Define a function f(l,r)

原创 ZOJ Problem Set - 4016 Mergeable Stack

題目連接 題意 有N個棧,三種操作。 1 a b 在棧a中壓入b 2 a 彈出棧a的棧頂元素,若a棧爲空,則輸出"EMPTY",否則輸出被彈出的棧頂元素。 3 a b 將b棧中的元素移到a棧上 思路 用STL 的stack

原创 ZOJ - 4034 Mahjong Sorting

DreamGrid has just found a set of Mahjong with 3M suited tiles and a White Dragon tile in his pocket. Each suited til

原创 UVALive 6175 Maximum Random Walk

Consider the classic random walk: at each step, you have a 1/2 chance of taking a step to the left and a 1/2 chance o

原创 Pagodas UVALive 7241

n pagodas were standing erect in Hong Jue Si between the Niushou Mountain and the Yuntai Mountain, labelled from 1 to

原创 Chip Factory

John is a manager of a CPU chip factory, the factory produces lots of chips everyday. To manage large amounts of prod

原创 字符串哈希到整數函數,算法

基本概念 所謂完美哈希函數,就是指沒有衝突的哈希函數,即對任意的 key1 != key2 有h(key1) != h(key2)。 設定義域爲X,值域爲Y, n=|X|,m=|Y|,那麼肯定有m>=n,如果對於不同的key1,key

原创 常數多項式、零次多項式和零多項式的差別

f(x)=aa≠0爲0次多項式f(x)=aa≠0爲0次多項式 0次指的是x的次方數爲0,正確應該寫成ax^0 ,只是因爲ax^0=a* 1=a 所以x^0被省略了不寫 舉例 如果f(x)= ax3+bx2+cx+d爲零次多項式 表

原创 讓你提升命令行效率的 Bash 快捷鍵 [完整版]

生活在 Bash shell 中,熟記以下快捷鍵,將極大的提高你的命令行操作效率。 編輯命令 Ctrl + a :移到命令行首 Ctrl + e :移到命令行尾 Ctrl + f :按字符前移(右向) Ctrl + b :按字符後移

原创 m-ary Partitions

A partition of an integer n is a set of positive integers which sum to n, typically written in descending order. For