随笔分类 - 算法练习
摘要:KMP算法说明:http://zh.wikipedia.org/wiki/%E5%85%8B%E5%8A%AA%E6%96%AF-%E8%8E%AB%E9%87%8C%E6%96%AF-%E6%99%AE%E6%8B%89%E7%89%B9%E7%AE%97%E6%B3%95#includeusin...
阅读全文
摘要:ProblemIt’s opening night at the opera, and your friend is the prima donna (the lead female singer). You will not be in the audience, but you want to ...
阅读全文
摘要:ProblemIt’s opening night at the opera, and your friend is the prima donna (the lead female singer). You will not be in the audience, but you want to ...
阅读全文
摘要:看《编程之美》的第一题就很有意思:写一个程序,让用户来决定Windows任务管理器的CPU占用率。可以实现下面三种情况:1. CPU的占用率固定在50%,为一条直线;2. CPU的占用率为条直线,但是具体占用率由命令行参数觉得(1~100);3.CPU的占用率状态是一个正弦曲线问题一我开始是按照书上...
阅读全文
摘要:Google Code Jam Qualification Round Africa 2010 的第一题,很简单。ProblemYou receive a creditCat a local store and would like to buy two items. You first walk ...
阅读全文
摘要:Google Code Jam 2008 资格赛的第一题:Saving the Universe。问题描述如下:ProblemThe urban legend goes that if you go to the Google homepage and search for "Google", th...
阅读全文
摘要:约瑟夫斯问题(有时也称为约瑟夫斯置换),是一个出现在计算机科学和数学中的问题。在计算机编程的算法中,类似问题又称为约瑟夫环。有个囚犯站成一个圆圈,准备处决。首先从一个人开始,越过个人(因为第一个人已经被越过),并杀掉第k个人。接着,再越过个人,并杀掉第k个人。这个过程沿着圆圈一直进行,直到最终只剩下...
阅读全文
摘要:利用栈实现判断字符串中的括号是否都是配对的。主要算法是依次读取字符串中的每一个字符,如果是左括号则将左括号压入栈中,如果是右括号则从栈中弹出最上面的字符,若两者不是同种括号或栈内已经没有字符就返回false,循环完成后返回true。package com.example;/** * Created ...
阅读全文
摘要:用java实现一个简单的矩阵类,可以实现简单的矩阵计算功能。class Matrix1.向量点乘public static double dot(double[] x,double[] y)2.矩阵和向量之积public static double[] mult(double[][] a,doub...
阅读全文

浙公网安备 33010602011771号