随笔分类 -  Algorithm

上一页 1 ··· 4 5 6 7 8 9 10 11 12 ··· 16 下一页
classic algorithm, problem
摘要:#include #include using namespace std;class Number {public: int a; int b; int c; Number(int _a = 0, int _b = 0, int _c = 0): a(_a), b(_b),... 阅读全文
posted @ 2014-11-04 00:09 卖程序的小歪 阅读(481) 评论(0) 推荐(0)
摘要:#include #include #include using namespace std;char tbl[5] = {'S', 'H', 'C', 'D', 'J'};void shuffle(vector &card, vector &rnd) { int rlen= rnd.size... 阅读全文
posted @ 2014-11-02 20:59 卖程序的小歪 阅读(247) 评论(0) 推荐(0)
摘要:#include #include #include using namespace std;char line[82];char space[82];int main() { scanf("%s", line); int len = strlen(line); int side_... 阅读全文
posted @ 2014-11-02 20:13 卖程序的小歪 阅读(180) 评论(0) 推荐(0)
摘要:#include #include #include using namespace std;char tbl[] = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A',... 阅读全文
posted @ 2014-11-02 19:56 卖程序的小歪 阅读(143) 评论(0) 推荐(0)
摘要:#include #include #include #include using namespace std;int main() { int n = 0; cin>>n; getchar(); vector strs; for (int i=0; i= len) b... 阅读全文
posted @ 2014-10-31 22:23 卖程序的小歪 阅读(235) 评论(0) 推荐(0)
摘要:#include #include #include #include using namespace std;class Stu { public: char name[12]; char id[12]; int grade; char... 阅读全文
posted @ 2014-10-31 21:24 卖程序的小歪 阅读(228) 评论(0) 推荐(0)
摘要:#include #include #include #include using namespace std;void print(vector &num) { int len = num.size(); bool value_begin = false; for (int i=... 阅读全文
posted @ 2014-10-31 20:18 卖程序的小歪 阅读(203) 评论(0) 推荐(0)
摘要:#include #include #include using namespace std;void print(int d[], int s, int e, const char* msg) { printf("%s\n", msg); if (s == e) { pr... 阅读全文
posted @ 2014-10-30 23:05 卖程序的小歪 阅读(161) 评论(0) 推荐(0)
摘要:参见:http://www.cnblogs.com/uvsjoh/archive/2012/03/27/2420120.html函数太多了,如上述文章中所述,BKDRHash算法在实现方便且表现出色,摘录其C的实现 1 unsigned int BKDRHash(char *str) 2 { 3 ... 阅读全文
posted @ 2014-10-17 08:52 卖程序的小歪 阅读(2385) 评论(0) 推荐(1)
摘要:#include #include #include using namespace std;bool double_num(vector &num) { int carry = 0; int i = num.size() - 1; while (i>=0) { in... 阅读全文
posted @ 2014-10-16 15:10 卖程序的小歪 阅读(198) 评论(0) 推荐(0)
摘要:#include #include #include using namespace std;class Node {public: vector adj; bool visited; Node() : visited(false) {}};void reset_nodes(vec... 阅读全文
posted @ 2014-10-16 10:37 卖程序的小歪 阅读(290) 评论(0) 推荐(0)
摘要:#include #include #include #include using namespace std;void init_primes(vector& primes) { int len = primes.size(); for (int i=0; i rs; while... 阅读全文
posted @ 2014-10-16 09:15 卖程序的小歪 阅读(174) 评论(0) 推荐(0)
摘要:#include #include #include using namespace std;class City {public: vector adj; bool visited; City() : visited(false) {}};void dfs(int idx, v... 阅读全文
posted @ 2014-10-16 00:07 卖程序的小歪 阅读(193) 评论(0) 推荐(0)
摘要:#include #include #include #include #include using namespace std;class User {public: vector fellowers; bool visited; User(): visited(false){}... 阅读全文
posted @ 2014-10-15 20:09 卖程序的小歪 阅读(174) 评论(0) 推荐(0)
摘要:过了一天感觉没干什么,想刷一发题弥补一下,正在考虑去做哪道,室友说去试试PAT 1010,果然当年自己直接跳过了这题,一看这通过率(0.07)有点夸张了。题目是已知一个数,求另外一个数的基数,使得这两个数数值上相等。很自然的考虑到使用二分搜索来确定这个基数,数字表示使用[0-9a-z],这tmd的让... 阅读全文
posted @ 2014-10-15 16:21 卖程序的小歪 阅读(1385) 评论(1) 推荐(0)
摘要:#include #include #include #include #include #include using namespace std;#define AGE_MAX 200class People {public: char name[9]; int worth; i... 阅读全文
posted @ 2014-10-13 01:45 卖程序的小歪 阅读(240) 评论(0) 推荐(0)
摘要:1 #include 2 #include 3 #include 4 #include 5 #include 6 7 using namespace std; 8 9 class Node {10 public:11 int val;12 Node* left;13 ... 阅读全文
posted @ 2014-09-27 11:40 卖程序的小歪 阅读(254) 评论(0) 推荐(0)
摘要:1 #include 2 #include 3 #include 4 #include 5 6 using namespace std; 7 8 class Solution { 9 public:10 vector fullJustify(vector &words, int... 阅读全文
posted @ 2014-09-22 10:34 卖程序的小歪 阅读(182) 评论(0) 推荐(0)
摘要:class Solution {public: // a valid number should be in the below form // -/+digit.digitE/e+/-digit bool isNumber(const char *s) { if (... 阅读全文
posted @ 2014-09-22 10:29 卖程序的小歪 阅读(155) 评论(0) 推荐(0)
摘要:class Solution {public: int atoi(const char *str) { if (str == NULL) return 0; long val =0, pos = 0; char ch = '\0'; in... 阅读全文
posted @ 2014-09-20 00:51 卖程序的小歪 阅读(220) 评论(0) 推荐(0)

上一页 1 ··· 4 5 6 7 8 9 10 11 12 ··· 16 下一页