摘要:产生伪随机数时给出的步长step和上限mod,判断下这两个值是否可以让产生的随机数均匀分布,所谓的均匀分布就是在mod步里能产生出0到mod-1这mod个数。
阅读全文
摘要:题目地址:http://acm.hdu.edu.cn/showproblem.php?pid=1013 #include #include using namespace std; void DigitRoot(int n) { int tmp; int sum = 0; while (n!=0) { tmp = n%10; sum += tmp; n = n/10;...
阅读全文
摘要:古人云:“由简入奢易,由奢入简难”,咱写代码也是一样,不求最快,但求最繁,繁得让你都不忍读完它。。。。
阅读全文
摘要:题目地址:http://acm.hdu.edu.cn/showproblem.php?pid=1008 #include using namespace std; int main(int argc, char *argv[]) { int n,curLev,desLev,sumTime,tmp; while(cin>>n&&n!=0) { curLev = 0;//初始层为0 sumTim...
阅读全文
摘要:题目地址:http://acm.hdu.edu.cn/showproblem.php?pid=1003 Code highlighting produced by Actipro CodeHighlighter (freeware)http://www.CodeHighlighter.com/-->#include #include using namespace std; in...
阅读全文
摘要:题目地址:http://acm.hdu.edu.cn/showproblem.php?pid=1002 #include #include using namespace std; void Add(string a,string b,char sum[],int& count) {//大数加法 int len1 = a.length();//数a的长度 int len2 = ...
阅读全文
摘要:Code highlighting produced by Actipro CodeHighlighter (freeware)http://www.CodeHighlighter.com/-->#include #include #include #include using namespace std;template void deSelSort(T arr[],int n){//双端选择排...
阅读全文
摘要:两个理念: 1)抽象。例如先基于晶体管描述逻辑门的实现,一旦领会了逻辑门的抽象,就将其细节丢弃,而是将其视为已经可以直接使用的组件,只有在系统出现问题时,才返回到细节中去进行分析 2)软硬件不加以区分。具体功能到底由谁来实现,以及两者之间的协作,依据的原则只是如何让计算机工作得更好, 图灵机以及图灵解决的问题:计算的可定义性 机器视角来看:从最底层的器件(最终是电子运动),接着是逻辑门电...
阅读全文
摘要:读了codeproject上的这篇《An introduction to bitwise operators》,前面两个运算符说得不错,但第三个异或运算符感觉不够准确,作者给出的示例不知道有什么用处,不就是把数做了两次异或又回来了么? &运算符用来判定某些位是0还是1: #include using namespace std;int main(void){ int num = 17; ...
阅读全文