- 博客(50)
- 收藏
- 关注
原创 poj 3685 Matrix 二分里套二分
Description Given a N × N matrix A, whose element in the i-th row and j-th column Aij is an number that equals i2 + 100000 × i + j2 - 100000 × j + i × j, you are to find the M-th smallest element in t
2015-08-26 21:24:26 453
原创 zoj3471 Most Powerful 状压dp
Description Recently, researchers on Mars have discovered N powerful atoms. All of them are different. These atoms have some properties. When two of these atoms collide, one of them disappears and a l
2015-08-26 21:10:58 318
原创 zoj2156 Charlie's Change 完全背包+路径记录
Description Charlie is a driver of Advanced Cargo Movement, Ltd. Charlie drives a lot and so he often buys coffee at coffee vending machines at motorests. Charlie hates change. That is basically the s
2015-08-26 20:51:35 443
原创 zoj2059 The Twin Towers (dp)
Description Twin towers we see you standing tall, though a building’s lost our faith will never fall. Twin towers the world hears your call, though you’re gone it only strengthens our resolve. We
2015-08-26 20:38:55 885
原创 zoj1986 Bridging Signals (dp,最长递增序列,LIS)
A - Bridging Signals Time Limit:2000MS Memory Limit:65536KB 64bit IO Format:%lld & %llu SubmitStatusPracticeZOJ 1986 Description ‘Oh no, they’ve done it again’, cries the chief designer at
2015-08-26 20:30:34 779
原创 hdu5418 BestCoder Round #52 (div.2) Victor and World ( floyd+状压dp)
Problem Description After trying hard for many years, Victor has finally received a pilot license. To have a celebration, he intends to buy himself an airplane and fly around the world. There are n co
2015-08-26 20:20:50 800
原创 zoj 2297 Survival 状压dp
Description The King of Fighter 97 (KOF97) is an electronic game of wrestling type. Once it was fashionable among youths. The game is amused. However, playing by oneself is not as excited as with frie
2015-08-26 20:10:30 821
原创 poj 3625 Building Roads 最小生成树(prime或kruskal+并查集)(算法归纳)
Time Limit:1000MS Memory Limit:65536KB 64bit IO Format:%I64d & %I64u Description Farmer John had just acquired several new farms! He wants to connect the farms with roads so that he can trave
2015-08-26 19:55:54 934
转载 set 的排序,及自定义排序
C++的容器大多数都是自动排序的,所以你使用这些容器时,你加入的元素类型必须是可以比较大小的,如果不是,则需要自定义排序规则,例如你自定义的结构体:[cpp] view plaincopy#include #include using namespace std; struct ju { int id,x
2015-08-22 22:57:11 582
原创 hdu1162 Eddy's picture 并查集+最小生成树
Problem Description Eddy begins to like painting pictures recently ,he is sure of himself to become a painter.Every day Eddy draws pictures in his small room, and he usually puts out his newest pictur
2015-08-17 21:03:18 366
原创 hdu1875 畅通工程再续 并查集+kruskal最小生成树
Problem Description 相信大家都听说一个“百岛湖”的地方吧,百岛湖的居民生活在不同的小岛中,当他们想去其他的小岛时都要通过划小船来实现。现在政府决定大力发展百岛湖,发展首先要解决的问题当然是交通问题,政府决定实现百岛湖的全畅通!经过考察小组RPRush对百岛湖的情况充分了解后,决定在符合条件的小岛间建上桥,所谓符合条件,就是2个小岛之间的距离不能小于10米,也不能大于1000米。
2015-08-17 20:40:32 648
原创 hdu1874 畅通工程续 最短路 floyd或dijkstra或spfa
Problem Description 某省自从实行了很多年的畅通工程计划后,终于修建了很多路。不过路多了也不好,每次要从一个城镇到另一个城镇时,都有许多种道路方案可以选择,而某些方案要比另一些方案行走的距离要短很多。这让行人很困扰。现在,已知起点和终点,请你计算出要从起点到终点,最短需要行走多少距离。Input 本题目包含多组数据,请处理到文件结束。 每组数据第一行包含两个正整数N和M(0#
2015-08-17 18:05:30 873
原创 hdu1863 畅通工程 并查集+最小生成树
Problem Description 省政府“畅通工程”的目标是使全省任何两个村庄间都可以实现公路交通(但不一定有直接的公路相连,只要能间接通过公路可达即可)。经过调查评估,得到的统计表中列出了有可能建设公路的若干条道路的成本。现请你编写程序,计算出全省畅通需要的最低成本。Input 测试输入包含若干测试用例。每个测试用例的第1行给出评估的道路条数 N、村庄数目M ( < 100 );随后的
2015-08-17 16:51:50 644
原创 hdu1233还是畅通工程 最小生成树(prim或kruskal)
Problem Description 某省调查乡村交通状况,得到的统计表中列出了任意两村庄间的距离。省政府“畅通工程”的目标是使全省任何两个村庄间都可以实现公路交通(但不一定有直接的公路相连,只要能间接通过公路可达即可),并要求铺设的公路总长度为最小。请计算最小的公路总长度。Input 测试输入包含若干测试用例。每个测试用例的第1行给出村庄数目N ( < 100 );随后的N(N-1)/2行对
2015-08-17 16:35:36 605
原创 hdu 1213 How Many Tables 并查集
Problem Description Today is Ignatius’ birthday. He invites a lot of friends. Now it’s dinner time. Ignatius wants to know how many tables he needs at least. You have to notice that not all the friend
2015-08-17 14:31:46 406
原创 hdu2473 Junk-Mail Filter 并查集+删除节点+路径压缩
DescriptionRecognizing junk mails is a tough task. The method used here consists of two steps: 1) Extract the common characteristics from the incoming email. 2) Use a filter matching the set of
2015-08-17 13:51:16 646
原创 hdu1796 How many integers can you find 容斥原理
Description Now you get a number N, and a M-integers set, you should find out how many integers which are small than N, that they can divided exactly by any integers in the set. For example, N=12
2015-08-16 22:15:34 580
原创 hdu1796 How many integers can you find 容斥原理
Description Now you get a number N, and a M-integers set, you should find out how many integers which are small than N, that they can divided exactly by any integers in the set. For example, N=12, a
2015-08-16 22:13:18 373
原创 hdu 1061Rightmost Digit 模幂运算
Description Given a positive integer N, you should output the most right digit of N^N. Input The input contains several test cases. The first line of the input is a single integer T which is the numb
2015-08-16 21:19:15 543
原创 hdu 1097 A hard puzzle 模幂运算
Description lcy gives a hard puzzle to feng5166,lwg,JGShining and Ignatius: gave a and b,how to know the a^b.everybody objects to this BT problem,so lcy makes the problem easier than begin. this puz
2015-08-16 21:08:54 346
原创 hdu 1212 Big Number 大数取模
Description As we know, Big Number is always troublesome. But it’s really important in our ACM. And today, your task is to write a program to calculate A mod B. To make the problem easier, I promise t
2015-08-16 21:02:20 454
原创 hdu 1108 最小公倍数
Description 给定两个正整数,计算这两个数的最小公倍数。Input 输入包含多组测试数据,每组只有一行,包括两个不大于1000的正整数.Output 对于每个测试用例,给出这两个数的最小公倍数,每个实例输出一行。 Sample Input 10 14 Sample Output 70 辗转相除#include<cstdio>#include<cmath>#include<cs
2015-08-16 20:58:46 359
原创 hdu1788 Chinese remainder theorem again 最小公倍数
Description我知道部分同学最近在看中国剩余定理,就这个定理本身,还是比较简单的: 假设m1,m2,…,mk两两互素,则下面同余方程组: x≡a1(mod m1) x≡a2(mod m2) … x≡ak(mod mk) 在0记Mi=M/mi(1ei≡0(mod mj),j!=i ei≡1(mod mj),j=i 很显然,e1a1+e2a2+…
2015-08-16 20:55:46 378
原创 codeforces 245C Game with Coins
Description Two pirates Polycarpus and Vasily play a very interesting game. They have n chests with coins, the chests are numbered with integers from 1 to n. Chest number i has ai coins.Polycarpus and
2015-08-12 17:43:48 470
原创 zoj3228 Searching the String AC自动机
Description Little jay really hates to deal with string. But moondy likes it very much, and she’s so mischievous that she often gives jay some dull problems related to string. And one day, moondy gave
2015-08-12 17:40:25 694
原创 Codeforces Round #Pi (Div. 2) B Berland National Library
B. Berland National Library time limit per test1 second memory limit per test256 megabytes inputstandard input outputstandard output Berland National Library has recently been built in the capital
2015-08-12 17:37:16 622
原创 zoj1654 Place the Robots
题目描述: Robert 是一个著名的工程师。一天,他的老板给他分配了一个任务。任务的背景是:给定一 个m×n 大小的地图,地图由方格组成,在地图中有3 种方格-墙、草地和空地,他的老板希望 能在地图中放置尽可能多的机器人。每个机器人都配备了激光枪,可以同时向四个方向(上、下、 左、右)开枪。机器人一直待在最初始放置的方格处,不可移动,然后一直朝四个方向开枪。激 光枪发射出的激
2015-08-12 17:05:05 593
转载 广义Fibonacci数列找循环节
转载http://blog.csdn.net/ACdreamers/article/details/25616461 今天将来学习如何求广义Fibonacci数列的循环节。问题:给定,满足,求的循 环节长度。来源:http://acdreamoj.sinaapp.com/ 1075题分析:我们知道矩阵的递推关系如下 然后继续有 那么,现在的问题就转化为求最小的,使得 所以我们可以先找出
2015-08-12 17:01:16 512
转载 数学期望
近年的acm竞赛中,数学期望问题常有涉及,在以前也常让本人感到很头疼,近来突然开窍,掌握了基本的分析方法,希望对大家有帮助。写得浅薄,可能数学上不够严谨,只供理解。 首先,来看下期望有啥基本的公式。 对离散型随机变量x,其概率为p,有简说期望类问题的解法 - Kicd - Kicds 对随机变量A、B,有 简说期望类问题的解法 - Kicd - Kicds 第二条式子
2015-08-11 21:13:12 790
原创 输入外挂
int Scan() { int res = 0, ch, flag = 0; if((ch = getchar()) == '-') //判断正负 flag = 1; else if(ch >= '0' && ch <= '9') //得到完整的数 res = ch - '0';
2015-08-11 16:20:52 434
转载 大素数,大整数质因数分解模板
#include <stdio.h>#include <algorithm>#include <math.h>#include <stdlib.h>#include <string.h>#include <time.h>using namespace std;typedef __int64 LL ;LL pri[] = {2, 3, 5, 7, 11, 13, 17, 19, 23, 2
2015-08-11 16:17:18 659
转载 ubuntu windows 双系统开机默认启动
我用的是ubuntu10.10和windows 7,最近经常用ubuntu系统,因此希望开机自动启动。研究成功之后,写出来,与大家分享,希望对大家有所帮助。操作过程如下:在终端中输入:sudo gedit /boot/grub/grub.cfg(此时可能需要输入密码,输入就可以了)打开之后,会看到如下文档(需要修改的位置,可以根据打开文档的滚动条的大体位置进行定位)wind
2015-08-10 14:26:48 1528
转载 大数分解模板
1.Miller-Rabin 算法(基于费马小定理/Fermat 定理)作用:通过概率的方式判断素数。有误判概率,通过多次判断可以使误判概率控制在很小范围。理论基础:如果n是一个奇素数, 将n-1表示成2^s*r的形式(r是奇 数),a 是和n互素的任何整数, 那么a^r≡1(mod n) 或者对某个j(0≤j ≤s -1, j∈Z) 等式 a^(2^j*r) ≡-1(mod
2015-08-08 21:30:41 844
原创 poj2187 Beauty Contest 凸包
DescriptionBessie, Farmer John’s prize cow, has just won first place in a bovine beauty contest, earning the title ‘Miss Cow World’. As a result, Bessie will make a tour of N (2 <= N <= 50,000) farms a
2015-08-07 20:55:25 692
原创 poj1228 Grandpa's Estate 凸包
DescriptionBeing the only living descendant of his grandfather, Kamran the Believer inherited all of the grandpa’s belongings. The most valuable one was a piece of convex polygon shaped farm in the gra
2015-08-07 20:49:12 711
原创 poj1113 Wall 凸包
DescriptionOnce upon a time there was a greedy King who ordered his chief Architect to build a wall around the King’s castle. The King was so greedy, that he would not listen to his Architect’s proposa
2015-08-07 20:42:42 938
转载 凸包问题
凸包问题 —— Graham扫描法:(1)找出点集p[]中最左下的点p1,把p1同点集中其他各点用线段连接,并计算这些线段与水平线的夹角,然后按夹角从小到大和按到p1的距离从近到远排序(夹角范围为 [0, 180)度,而且可以删除相同夹角且距离p1较近的点,保留最远点,这样可减少计算量。因为直线上的非端点不是凸包的极点,即如果p1,p2,p3在一条直线上,则只取凸点p1,p3。p2不在端点
2015-08-06 21:12:00 485
转载 dancing links 算法 解 Sudoku
1. Danclink links 算法解Sudoku的基本思想: 将Sudoku问题转化为等价的01矩阵问题,然后用dlx算法求解。从一个由0 1组成的矩阵中找到一个行的集合,使得集合中每列恰好包含一个1,称为01矩阵问题。解决它的dancling links 算法利用双向链表的一个性质,巧妙的剪枝,获得了较好的性能 A) 构造01矩阵01矩阵问题是什么?01矩阵
2015-08-06 20:20:16 542
转载 cmd命令
cmd命令大全(第一部分) winver———检查Windows版本 wmimgmt.msc—-打开windows管理体系结构(WMI) wupdmgr——–windows更新程序 wscript——–windows脚本宿主设置 write———-写字板 winmsd———系统信息 wiaacmgr——-扫描仪和照相机向导 winchat
2015-08-05 20:19:09 592
转载 树状数组(木有看到图)
树状数组中用的d【】,每个点都有一定的管辖范围; 如d[1]=a[1]; d[2]=a[1]+a[2]; d[3]=a[3]; d[4]=a[1]+a[2]+a[3]+a[4]; 等等; 这样的结构关键是为了,对一个数组内部动态的删除,增加,来高效的求某个点或者某个区间的值; 比如说对数组a,改变某一位的值需O(1),求某个k区间值O(k); 这样的m次操作是用O(m*k); 显然
2015-08-05 17:10:29 406
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人