随笔分类 - Algorithm
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),...
阅读全文
摘要:#include #include #include using namespace std;char tbl[5] = {'S', 'H', 'C', 'D', 'J'};void shuffle(vector &card, vector &rnd) { int rlen= rnd.size...
阅读全文
摘要:#include #include #include using namespace std;char line[82];char space[82];int main() { scanf("%s", line); int len = strlen(line); int side_...
阅读全文
摘要:#include #include #include using namespace std;char tbl[] = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A',...
阅读全文
摘要:#include #include #include #include using namespace std;int main() { int n = 0; cin>>n; getchar(); vector strs; for (int i=0; i= len) b...
阅读全文
摘要:#include #include #include #include using namespace std;class Stu { public: char name[12]; char id[12]; int grade; char...
阅读全文
摘要:#include #include #include #include using namespace std;void print(vector &num) { int len = num.size(); bool value_begin = false; for (int i=...
阅读全文
摘要:#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...
阅读全文
摘要:参见:http://www.cnblogs.com/uvsjoh/archive/2012/03/27/2420120.html函数太多了,如上述文章中所述,BKDRHash算法在实现方便且表现出色,摘录其C的实现 1 unsigned int BKDRHash(char *str) 2 { 3 ...
阅读全文
摘要:#include #include #include using namespace std;bool double_num(vector &num) { int carry = 0; int i = num.size() - 1; while (i>=0) { in...
阅读全文
摘要:#include #include #include using namespace std;class Node {public: vector adj; bool visited; Node() : visited(false) {}};void reset_nodes(vec...
阅读全文
摘要:#include #include #include #include using namespace std;void init_primes(vector& primes) { int len = primes.size(); for (int i=0; i rs; while...
阅读全文
摘要:#include #include #include using namespace std;class City {public: vector adj; bool visited; City() : visited(false) {}};void dfs(int idx, v...
阅读全文
摘要:#include #include #include #include #include using namespace std;class User {public: vector fellowers; bool visited; User(): visited(false){}...
阅读全文
摘要:过了一天感觉没干什么,想刷一发题弥补一下,正在考虑去做哪道,室友说去试试PAT 1010,果然当年自己直接跳过了这题,一看这通过率(0.07)有点夸张了。题目是已知一个数,求另外一个数的基数,使得这两个数数值上相等。很自然的考虑到使用二分搜索来确定这个基数,数字表示使用[0-9a-z],这tmd的让...
阅读全文
摘要:#include #include #include #include #include #include using namespace std;#define AGE_MAX 200class People {public: char name[9]; int worth; i...
阅读全文
摘要: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 ...
阅读全文
摘要: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...
阅读全文
摘要:class Solution {public: // a valid number should be in the below form // -/+digit.digitE/e+/-digit bool isNumber(const char *s) { if (...
阅读全文
摘要:class Solution {public: int atoi(const char *str) { if (str == NULL) return 0; long val =0, pos = 0; char ch = '\0'; in...
阅读全文

浙公网安备 33010602011771号