上一页 1 ··· 3 4 5 6 7 8 9 10 11 12 下一页
摘要: poj3342View Code 1 #include <map> 2 #include <stdio.h> 3 #include <vector> 4 #include <string> 5 #include <iostream> 6 using namespace std; 7 const int N=205; 8 vector<int > V[N]; 9 map<string,int> M;10 string child,father;11 int dp[N][2];12 bool ok[N][2];13 阅读全文
posted @ 2013-01-19 01:36 _sunshine 阅读(1211) 评论(0) 推荐(0) 编辑
摘要: 梳理了一下字典序:hdu1251裸 字典树View Code 1 #include<stdio.h> 2 #include<string.h> 3 #include<iostream> 4 using namespace std; 5 struct trie{ 6 int cnt; 7 trie *next[26]; 8 }; 9 trie *root=new trie;10 void insert(char s[]){11 trie *p=root,*newnode;12 for(int i=0;s[i]!='\0';i++){13 if( 阅读全文
posted @ 2013-01-13 00:50 _sunshine 阅读(364) 评论(0) 推荐(0) 编辑
摘要: 斐波那契史:① 求斐波那契数的后四位,矩阵乘法+快速幂。② 求斐波那契数的前四位(n<100000000),用到斐波那契数的公式(Hdu1568)。③ 求斐波那契数的前40位(n<100000)(Hdu4099)。④ 求斐波那契“串”的某一位(百度之星)……斐波那契数公式:①矩阵+快速幂②hdu1568 先看对数的性质 loga(b^c)=c*loga(b),loga(b*c)=loga(b)+loga(c); Eg: log10(10234432)= log10(1.0234432*10^7)= log10(1.0234432)+7; log10(1.0234432)就是log1 阅读全文
posted @ 2013-01-11 17:09 _sunshine 阅读(813) 评论(0) 推荐(1) 编辑
摘要: 阶乘:View Code 1 import java.io.*; 2 import java.math.*; 3 public class BigInteger_factorial { 4 public static void main(String[] args) throws IOException{ 5 BigInteger s = BigInteger.valueOf(1); 6 for ( int i = 1;i<=500 ; i++){ 7 s = s.multiply(BigInteger.valueOf(i)... 阅读全文
posted @ 2013-01-11 15:52 _sunshine 阅读(428) 评论(0) 推荐(0) 编辑
摘要: Hdu1102 最小生成树 Prime算法(裸):首先有两个集合V{},边的集合E{}。先选择一个点,加入到V集合中,然后选择和这个V集合中的点相关连的边中最小的,将边的另一头的点加入到V集合中,该边加入到E集合中,V集合中的点是一个连通图,每次找和这个连通图相连的最短边,来更新。View Code 1 #include <stdio.h> 2 #include <string.h> 3 const int N=105; 4 const int inf=10000000; 5 int map[N][N],n; 6 int vis[N*(N+1)/2]; 7 int di 阅读全文
posted @ 2013-01-11 00:18 _sunshine 阅读(2438) 评论(0) 推荐(0) 编辑
摘要: A了4081顺便看了一下4082,感觉题目不好翻译,前几段都是没用的,意思就是给你n个点(0<n<18),数据范围很小…求这n个点能组成最多有多少个相似三角形。暴力枚举,但是要注意很多细节,首先:①去重点,在图论里总是会有去掉重边,可是计算几何里很少遇到去掉重点的问题,所以容易被遗忘,so……记住!!!!②判断三个点能否组成三角形,即是否共线。后台数据应该水了,一开始的代码,对于41 12 23 34 4这组数据输出1也AC了~View Code 1 #include <stdio.h> 2 #include <iostream> 3 #include &l 阅读全文
posted @ 2013-01-11 00:06 _sunshine 阅读(584) 评论(0) 推荐(0) 编辑
摘要: 好久没写题了,水一水练习一下吧:hdu1272判断连通无环图: 判断成环的时候,只要判断输入边的两个点。 有一个共同的父节点,那么这两个点就成环。 判断连通的时候,只要判断根节点数为1即可。View Code 1 #include <stdio.h> 2 #define N 100010 3 int father[N]; 4 int mark[N]; 5 int find(int x){ 6 if(x!=father[x]) 7 father[x]=find(father[x]); 8 return father[x]; 9 }10 void merge... 阅读全文
posted @ 2013-01-08 14:53 _sunshine 阅读(802) 评论(0) 推荐(0) 编辑
摘要: hdu3062链接:http://acm.hdu.edu.cn/showproblem.php?pid=3602poj3678链接:http://poj.org/problem?id=3678zoj3656链接:http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=3656poj3678应该是最简单的吧~~题意:有n个变量,每个可以取0或者1,再给出m组关系,每组关系都是两个变量进行运算可以得到的结果,运算有AND OR XOR三种,问能否根据这些关系,判断每个变量的取值。思路: 2-Sat问题,关键是要把所有情况考虑完全。用 阅读全文
posted @ 2012-11-05 21:31 _sunshine 阅读(394) 评论(0) 推荐(0) 编辑
摘要: 题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=3622题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1814hdu3622题意:给n对炸弹可以放置的位置(每个位置为一个二维平面上的点),每次放置炸弹是时只... 阅读全文
posted @ 2012-11-03 17:43 _sunshine 阅读(1236) 评论(4) 推荐(0) 编辑
摘要: 题目链接:http://poj.org/problem?id=3648题意有点纠结:一堆夫妇去参加一对新人的婚礼。人们坐在一个很长很长的桌子的两侧(面对面)。新郎新娘在桌子头面对面座。新娘不希望看见她对面的一排有一对夫妇坐着(夫妇需要分开两排座)。同时,一些人之间有通奸关系,新娘也不希望有通奸关系的人同时坐在她对面的一排。问你可否满足新娘的要求,可以的话,输出一种方案思路:把丈夫和新娘同一边看做点i,在新娘对面看做i+n。然后根据通奸关系进行构图。因为新郎也有可能有通奸关系,所以构图时加入新郎点0,增加一条边,0-->0+n。然后就是求解2-SAT问题了。第一道2-SAT问题,好几天没刷 阅读全文
posted @ 2012-11-02 18:09 _sunshine 阅读(555) 评论(2) 推荐(0) 编辑
上一页 1 ··· 3 4 5 6 7 8 9 10 11 12 下一页