Shirlies
宁静专注认真的程序媛~
上一页 1 ··· 10 11 12 13 14 15 16 17 18 ··· 21 下一页
摘要: 又有好久没有写博客了,主要是没怎么做题,汗……有点小忙吧~~~这一题坑了我,我搞不懂编译器咋这么差,这等错误都找不出来,我勒个去啊~~~害惨我了……~~~~(>_<)~~~~View Code 1 #include <cstdio> 2 #include <cmath> 3 4 const double er = 1e-6; 5 double p,q,r,s,t,u; 6 7 inline double get_value(double x) 8 { 9 return p*exp(-x)+ q*sin(x) + r*cos(x) + s*tan(x) + t 阅读全文
posted @ 2012-03-21 22:01 Shirlies 阅读(292) 评论(0) 推荐(0) 编辑
摘要: 用两个数组存储,再排序就OK了,如果有1 2,没有2 1,那么第二个数组排序后肯定没有1 2,那么就NO了~~~View Code 1 #include <cstdio> 2 #include <cstring> 3 #include <algorithm> 4 5 struct per 6 { 7 int start,end; 8 }; 9 per p[500010],rp[500010];10 11 bool cmp(per p1,per p2)12 {13 if(p1.start == p2.start)14 return p1.end < p2 阅读全文
posted @ 2012-03-15 15:57 Shirlies 阅读(195) 评论(0) 推荐(0) 编辑
摘要: View Code 1 #include <cstdio> 2 #include <cstring> 3 4 const int sonnum = 26; 5 char word[120005][30]; 6 struct trie 7 { 8 bool term; 9 struct trie *son[sonnum];10 };11 12 trie* create_trie()13 {14 trie *temp = new trie;15 temp -> term = false;16 for(int i = 0;i <sonnum;i++)17 ... 阅读全文
posted @ 2012-03-15 15:06 Shirlies 阅读(276) 评论(0) 推荐(0) 编辑
摘要: 一看到这一题,我真没想到用并查集做,坑啊,看看别人的大致思路才知道用并查集可以做,唉,看来是自己太弱了~~~View Code 1 #include <cstdio> 2 #include <cstring> 3 4 int pipe[11][4]={{1,0,0,1},{1,1,0,0},{0,0,1,1}, 5 {0,1,1,0},{1,0,1,0},{0,1,0,1},{1,1,0,1},{1,0,1,1}, 6 {0,1,1,1},{1,1,1,0},{1,1,1,1}};//将每个都编号了,并且用上了边 7 int f[3000]; 8 int map[300 阅读全文
posted @ 2012-03-10 00:02 Shirlies 阅读(459) 评论(0) 推荐(0) 编辑
摘要: sg值但是这一题要注意一点,就是N值大于等于M值时考虑。View Code 1 #include <cstdio> 2 #include <cstring> 3 4 int sg[1101]; 5 int mex[1101]; 6 int m,n; 7 8 void get_sg() 9 {10 int i,j;11 sg[0] = 0;12 for(i = 1;i <1101;i ++)13 {14 memset(mex,0,sizeof(mex));15 for(j = 1;j <=n ;j ++)16 ... 阅读全文
posted @ 2012-03-09 21:25 Shirlies 阅读(231) 评论(0) 推荐(0) 编辑
摘要: 求sg值就行了View Code 1 #include <cstdio> 2 #include <cstring> 3 4 int fib[1000]; 5 int sg[1100]; 6 int mex[1000]; 7 int num_fib; 8 9 void cal_fib()10 {11 fib[0] = 1;12 fib[1] = 1;13 int i;14 for(i = 2;i < 1000;i ++)15 {16 fib[i] = fib[i-1] + fib[i-2];17 if(fib[i] >... 阅读全文
posted @ 2012-03-09 20:55 Shirlies 阅读(373) 评论(0) 推荐(0) 编辑
摘要: 这一题是与并查集删除节点有关的,我想不出来怎么做,看了别人的解题思路,也依葫芦画瓢写了份代码,代码就没有必要贴了,说说自己看了别人解题思路后自己的理解吧。这一题是要求我们删除集合中的数并另外占一个集合,大家的思路基本上都是:用虚拟节点做父节点(之前的并查集,我们都是用自己做自己的父节点),我们修改的也只是与一个数关联的父节点。说是这样说,但是方法要想出来还是要费一番周折的。提供两种链接代码http://www.cppblog.com/MiYu/archive/2010/08/26/124771.htmlhttp://www.cnblogs.com/fornever/archive/2011/1 阅读全文
posted @ 2012-03-09 15:15 Shirlies 阅读(664) 评论(0) 推荐(0) 编辑
摘要: 这是一道关于博弈的题目,这一题挺不错的,如果知道了nim游戏异或的道理,这一题是比较好写的。Nim游戏的局面(a1,a2,...,an),它是P-position当且仅当a1^a2^...^an=0,其中^表示异 或(xor)运算。•对于某个局面(a1,a2,...,an),若a1^a2^...^an==k(k>0)•一定存在某个合法的移动,将ai改变成ai'后满足 a1^a2^...^ai'^...^an=0•一定存在某个ai,它的二进制表示在k的最高位上是1 (ai^k<ai 成立)•将ai改变成ai'=ai^k a1^a2^...^ai'^.. 阅读全文
posted @ 2012-03-09 09:36 Shirlies 阅读(948) 评论(2) 推荐(0) 编辑
摘要: 做完之后,想看看别人是怎么做的,翻了一下别人的代码,晕,那个简洁啊,直接模3……我还是贴我自己的代码吧,我是想求SG值来着的……View Code 1 #include <cstdio> 2 3 int index[11]={1,2,4,8,16,32,64,128,256,512,1024}; 4 int n; 5 int vic[1002]={0}; 6 7 int main() 8 { 9 int i;10 11 for(i=1;i<1002;i ++)12 {13 int flag = 0;14 for(int j=0;j<... 阅读全文
posted @ 2012-03-07 13:15 Shirlies 阅读(524) 评论(0) 推荐(0) 编辑
摘要: 题意:起初球i是被放在i号城市的,在年代更迭,世事变迁的情况下,球被转移了,而且转移的时候,连带该城市的所有球都被移动了:T A B(A球所在的城市的所有球都被移动到了B球所在的城市),Q A(问:A球在那城市?A球所在城市有多少个球呢?A球被转移了多少次呢?)。这一题还是蛮有意思的,虽然第一次写的时候超时了,因为我没有利用好查找函数的递归性,在合并的时候用一个循环将本来可以在查找时就合并好的,又另外处理的。View Code 1 #include <cstdio> 2 #include <string> 3 #define MAX 10010 4 5 int rank 阅读全文
posted @ 2012-03-06 16:11 Shirlies 阅读(1374) 评论(1) 推荐(1) 编辑
上一页 1 ··· 10 11 12 13 14 15 16 17 18 ··· 21 下一页