09 2015 档案
摘要:1 #include 2 #include 3 #include 4 using namespace std; 5 6 int main() { 7 int x; 8 while(cin >> x) { 9 x = (x & 1) ? ( ( x & ((-...
阅读全文
摘要:代码: 1 #include 2 3 int add(int a, int b) { 4 if(a == 0 || b == 0) { 5 return a ^ b; 6 } 7 return add( (a&b) >= 1;25 }26 ...
阅读全文
摘要:大意:求最长回文字串:分析:1、暴力方法。。枚举头尾,判断是不是回文串 0(n^3)3、寻找中点往两边暴力 n^2代码 1 #include 2 #include 3 #include 4 using namespace std; 5 6 const int maxn = 55; 7 8...
阅读全文
摘要:1 #include 2 #include 3 using namespace std; 4 5 typedef int type; 6 7 template 8 struct Node { 9 T data;10 Node *next;11 Node() {1...
阅读全文
摘要:大意:告诉你有n个点 m个边的无向图 然后问有多少点对 他们的路径上节点之间的距离都少于 x分析:并查集代码: 1 #include 2 #include 3 #include 4 #include 5 using namespace std; 6 7 const long long ma...
阅读全文
摘要:给定一个单词a,如果通过交换单词中字母的顺序可以得到另外的单词b,那么定义b是a的兄弟单词,例如单词army和mary互为兄弟单词。现在给定一个字典,用户输入一个单词,如何根据字典找出这个单词有哪些兄弟单词?要求时间和空间效率尽可能的高。方案一:用hash来做 head中保存的是 排好序的字母顺序 ...
阅读全文
摘要:字典树 这一个比较简单 现在回顾也挺简单直接给出模板 有什么不会的直接去模板里理解 1 #include 2 #include 3 #include 4 using namespace std; 5 6 const int maxn = 500005; 7 int tire[maxn][26...
阅读全文
摘要:1 #include 2 #include 3 #include 4 #include 5 #include 6 using namespace std; 7 const int MAXN=550; 8 const double eps=1e-8; 9 10 struct Po...
阅读全文

浙公网安备 33010602011771号