摘要: #include #include #include #include using namespace std; #define LL long long //#define __int64 LL LL dp[22][3]; int pos[22]; //[][0] 包含49 //[][1] 最高位是9 但不含49 //[][2] 不含49 void initial() { dp[0][2]=1; for(int i = 1; i 10) { pos[cnt++] = a % 10; a /= 10; } pos[cnt]... 阅读全文
posted @ 2013-04-02 15:38 Felix_F 阅读(150) 评论(0) 推荐(0)
摘要: [出处太多我就不注明地址了,原帖地址有点难找,见谅]国家集训队论文分类组合数学计数与统计2001 - 符文杰:《Pólya原理及其应用》2003 - 许智磊:《浅谈补集转化思想在统计问题中的应用》2007 - 周冬:《生成树的计数及其应用》2008 - 陈瑜希《Pólya计数法的应用》数位问题2009 - 高逸涵《数位计数问题解法研究》2009 - 刘聪《浅谈数位类统计问题》动态统计2004 - 薛矛:《解决动态统计问题的两把利刃》2007 - 余江伟:《如何解决动态统计问题》博弈2002 - 张一飞:《由感性认识到理性认识——透析一类搏弈游戏的解答过程》2007 - 王晓 阅读全文
posted @ 2013-03-27 19:26 Felix_F 阅读(486) 评论(0) 推荐(0)
摘要: /*Template*/ #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; //type... 阅读全文
posted @ 2013-03-25 20:54 Felix_F 阅读(114) 评论(0) 推荐(0)
摘要: #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std;//typedef long long LL;//typedef __int64 LL; //typedef long ... 阅读全文
posted @ 2013-03-23 17:01 Felix_F 阅读(125) 评论(0) 推荐(0)
摘要: 原帖地址:http://www.matrix67.com/blog/archives/276不要以为数学中的矩阵也是黑色屏幕上不断变化的绿色字符。在数学中,一个矩阵说穿了就是一个二维数组。一个n行m列的矩阵可以乘以一个m行p列的矩阵,得到的结果是一个n行p列的矩阵,其中的第i行第j列位置上的数等于前一个矩阵第i行上的m个数与后一个矩阵第j列上的m个数对应相乘后所有m个乘积的和。比如,下面的算式表示一个2行2列的矩阵乘以2行3列的矩阵,其结果是一个2行3列的矩阵。其中,结果的那个4等于2*2+0*1:下面的算式则是一个1 x 3的矩阵乘以3 x 2的矩阵,得到一个1 x 2的矩阵:矩阵乘法的两个 阅读全文
posted @ 2013-03-20 13:22 Felix_F 阅读(795) 评论(0) 推荐(0)
摘要: A题我就不放了...岛娘出那个签到都水,大小写转换你也出...B题代码在上面了...final test 之前我是400...之后我就变200了...一看全都B题被卡掉的...rating 还+167 莫名其妙真是不知道发生了什么题意就是给你一个分数a/b,求分母小于c 且能使得abs( a/b - d/c ) 最小的分数...记得最后要化简坑很多第一个: int64第二个: 分母不能是0第三个: 循环每次都要GCD...不然可能爆int64第四个: 0/a = 0/1 (这个真坑)第五个: 如果abs( a/b - d/c )和abs( a/b - (d+1)/c ) 一样大...要对 d/ 阅读全文
posted @ 2013-03-13 20:31 Felix_F 阅读(115) 评论(0) 推荐(0)
摘要: 楼教主的二维线段树(树状数组) ---------------这一题是真的不知道怎么做 ,但还是AC了...题目我就不贴了...我就简单说一下题意:1000*1000的矩阵,给你50000个操作C操作 对从左上角(x1,y1)到右下角(x2,y2)的矩形中所有元素取反Q操作 查询某坐标下元素的值一看就是经典树状数组或者线段树了,大部分题解都很偷懒都是用二维树状数组的快速写法...我在这里就用二维线段树来解了,不过线段树明显开销比树状数组大很多,线段树在结构体上要开4倍这道题是二维因此比树状数组整整大了16倍,内存爆的很明显...用int绝对MLE无误...于是我用了short竟然... 阅读全文
posted @ 2013-03-13 20:09 Felix_F 阅读(155) 评论(0) 推荐(0)
摘要: Language:Ultra-QuickSortTime Limit:7000MSMemory Limit:65536KTotal Submissions:31077Accepted:11082DescriptionIn this problem, you have to analyze a particular sorting algorithm. The algorithm processes a sequence of n distinct integers by swapping two adjacent sequence elements until the sequence is 阅读全文
posted @ 2013-03-10 14:49 Felix_F 阅读(159) 评论(0) 推荐(0)
摘要: Language:StarsTime Limit:1000MSMemory Limit:65536KTotal Submissions:24726Accepted:10782Description Astronomers often examine star maps where stars are represented by points on a plane and each star has Cartesian coordinates. Let the level of a star be an amount of the stars that are not higher and n 阅读全文
posted @ 2013-03-08 12:41 Felix_F 阅读(173) 评论(0) 推荐(0)
摘要: /*Template*/ /*Poj 3270 Cow Sorting */ #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include u... 阅读全文
posted @ 2013-03-01 05:24 Felix_F 阅读(126) 评论(0) 推荐(0)
摘要: 题目传送门:http://www.acmore.net/JudgeOnline/contest.php?cid=1027A::难度值4考点:指针的运用CodeForce 251A 官方题解:Let's select the rightmost point of ourtriplet. In order to do this we can iterate over all points in ascending orderof their X-coordinate. At the same time we'll maintain a pointer to theleftmost 阅读全文
posted @ 2013-01-08 17:17 Felix_F 阅读(112) 评论(0) 推荐(0)
摘要: #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; int max(int a,int b){return ab?b:a;} long long x[55]={ 1,2,5,10,20,25,50, 100,125,200,250,500, 1000... 阅读全文
posted @ 2012-12-22 20:33 Felix_F 阅读(129) 评论(0) 推荐(0)
摘要: #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; int max(int a,int b){return ab?b:a;} int main() { int cas,t=1; cin>>cas; while(cas--) { doubl... 阅读全文
posted @ 2012-12-22 20:30 Felix_F 阅读(142) 评论(0) 推荐(0)
摘要: 打素数表,构造矩阵,然后BFS可得答案#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; int max(int a,int b){return ab?b:a;} const int maxn=200; bool p[maxn*maxn*2]; in... 阅读全文
posted @ 2012-12-22 20:27 Felix_F 阅读(141) 评论(0) 推荐(0)
摘要: 所有的题目百度都有,问问题前先百度,这是黄金定律所有题都给个思路:具体代码都可百度A:把素数筛出来,先构造原矩形,就是一个一个往下推,然后构造被挖掉合数的矩形遍历原矩形找到起点和终点,然后后构造的矩形中的素数就相当于障碍物,整个问题就化成一个迷宫问题了用BFS一搜就能得出最短距离B:具体证明:http://www.doc88.com/p-792551521271.html直接代最后的海伦公式C:分成左右两块,左边两列数枚举,右边两列数哈希构造哈希表O(n^2),枚举O(n^2)根据左边枚举的情况找右边的hash值就行了,hash用链表哈希不懂就百度,寒假一定要搞懂哈希下半年也会开哈希专题D:水 阅读全文
posted @ 2012-12-22 20:24 Felix_F 阅读(150) 评论(0) 推荐(0)
摘要: #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std;int max(int a,int b){return ab?b:a;}#define V 205#define INF 0x3f3f3f3fint cap[V][V],flow[V][V];// cap是每条边的容量,flow是每条边 阅读全文
posted @ 2012-12-11 04:53 Felix_F 阅读(136) 评论(0) 推荐(0)
摘要: #include#include#include#includeusing namespace std;const int N=205;const int INF=0x3f3f3f3f;int s[N][N];//记录图的邻接矩阵int d[N];//记录图中各点的层次int n,m;int min(int a,int b){ return aQ; memset(d,-1,sizeof(d));//此处初始化要特别注意,以上版本的初始化就存在很大问题 d[1]=0;//如果处理不慎就很容易死循环 Q.push(1); while(!Q.empty()){ ... 阅读全文
posted @ 2012-12-10 09:04 Felix_F 阅读(160) 评论(0) 推荐(0)
摘要: const int INF = 0x3f3f3f3f; const int MAXN=510; int uN,vN;//u,v数目 int g[MAXN][MAXN];//构图 int link[MAXN]; //link[v]=u表示右边对左边的匹配 bool used[MAXN];//是否访问过 bool dfs(int u)//从左边开始找增广路径 { int v; for(v=0;v<vN;v++)//右边顶点编号从0开始 { if(g[u][v]&&!used[v]) //如果存在通路,且从u开始搜索时该点没访问过 { used[v]=true... 阅读全文
posted @ 2012-12-04 08:44 Felix_F 阅读(148) 评论(0) 推荐(0)
摘要: #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; const int INF = 0x3fffffff; const int V = 200; int cmp(double a, double b) { return a>b; } int mai... 阅读全文
posted @ 2012-08-19 10:23 Felix_F 阅读(156) 评论(0) 推荐(0)
摘要: #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; const int INF = 0x3fffffff; const int V = 200; int main() { //freopen("in.txt","r",stdin); //freo 阅读全文
posted @ 2012-08-19 10:02 Felix_F 阅读(90) 评论(0) 推荐(0)
摘要: const int INF = 0x3fffffff; const int V = 200; int dijkstra(int map[][V],int start,int end,int n) //map为临界矩阵,n为矩阵大小 { int final[V],track[V],i,j,ant=n*n; memset(track,0,sizeof(track)); for(i=1;i<=n;i++) final[i]=map[start][i]!=0?map[start][i]:INF; track[start]=1; while(ant--) { int judge=1... 阅读全文
posted @ 2012-08-14 21:30 Felix_F 阅读(177) 评论(0) 推荐(0)
摘要: /* 很简单的模版题...Dijkstra应该就不用多说了...算法比较简单...尤其是数据结构中的...所以流程图都有...大家一搜一大堆我就不赘述了...赘述也是多余 给几组数据 3 3 1 2 1 1 3 3 2 3 1 3 1 1 2 1 6 9 1 2 7 1 3 9 1 4 14 2 3 10 2 5 15 3 4 2 3 5 11 4 6 9 5 6 6 6 8 1 3 10 1 5 30 1 6 100 2 3 5 3 4 50 4 6 10 5 4 20 5 6 60 **************************************************** . 阅读全文
posted @ 2012-08-14 13:21 Felix_F 阅读(133) 评论(0) 推荐(0)
摘要: /******************Kruskal********************/#include #include #include #include #include using namespace std;const int V = 101;int father[V],map[V]... 阅读全文
posted @ 2012-08-10 02:13 Felix_F 阅读(164) 评论(0) 推荐(0)
摘要: 最近刚学的并查集所以用kruskal来试试最小生成树~kruskal其实用几句话就能说完~1.贪心所有边的权值,从小到大取值2.取值时~将边权非0的两个顶点~进行并查操作~如果两个点的祖先不同...边权加入最小生成树...并且将两个点纳入同一个集合中3.判断是否所有点都在同一个集合中完毕~下面上代码~这个代码应该可以作为模版了...但是并查集没有优化~所以复杂度约为0(n^3)但是比prim好一点32ms水过...mian()前的代码修改一下可以作为kruskal的模版...我再写一篇专门放模版吧~#include #include #include #include #include... 阅读全文
posted @ 2012-08-10 02:01 Felix_F 阅读(163) 评论(0) 推荐(0)
摘要: Language:ParencodingsTime Limit:1000MSMemory Limit:10000KTotal Submissions:15029Accepted:8959DescriptionLet S = s1 s2...s2n be a well-formed string of parentheses. S can be encoded in two different ways:q By an integer sequence P = p1 p2...pn where pi is the number of left parentheses before the ith 阅读全文
posted @ 2012-08-09 12:44 Felix_F 阅读(181) 评论(0) 推荐(0)
摘要: #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; int main() { // freopen("in.txt","r",stdin); int a,b; while(cin>>a>>b) { int i,j; b=-b; int x[ 阅读全文
posted @ 2012-08-09 09:04 Felix_F 阅读(111) 评论(0) 推荐(0)
摘要: 题目很简单...给你N个星星的坐标...找出在m*n的方框中最多能容纳几个星星...直接遍历一遍整个图...属于简单搜索~#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; int map[501][501]; ... 阅读全文
posted @ 2012-08-09 02:34 Felix_F 阅读(130) 评论(0) 推荐(0)
摘要: 颤抖吧凡人~这才是真正的暴力枚举!!!枚举16个点的状态分别判断...真的...这样也能过...#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; int main() { // freopen("in.txt","r",stdin); int a,b,c,d,e 阅读全文
posted @ 2012-08-08 06:31 Felix_F 阅读(139) 评论(0) 推荐(0)
摘要: sort横坐标x...以岛屿为圆心.d为半径画圆...分别计算与x轴的左右交点按照从大到小的顺序(或者从小到大都行)对x轴的交点进行判断...#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; struct point { double x; double y; ... 阅读全文
posted @ 2012-08-07 19:08 Felix_F 阅读(109) 评论(0) 推荐(0)
摘要: =============================以下是最小生成树+并查集====================================== 【HDU】 1213 How Many Tables 基础并查集★ 1272 小希的迷宫 基础并查集★ 1325&&poj1308 Is It A Tree? 基础并查集★ 1856 More is better 基础并查集★ 1102 Constructing Roads 基础最小生成树★ 1232 畅通工程 基础并查集★ 1233 还是畅通工程 基础最小生成树★ 1863 畅通... 阅读全文
posted @ 2012-08-05 20:35 Felix_F 阅读(163) 评论(0) 推荐(1)