08 2015 档案
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=5424/*对于一个连通图,有N个顶点,如果有N条边,那么肯定有环因为N个点如果不成环最多N-1条边。。。然后找最小度的点DFS就行。。。 *//***********************************...
阅读全文
摘要:http://codeforces.com/contest/574/problem/D/*容易得到状态方程dp[i] = min(a[i], dp[i-1]+1,dp[i-2]+2 ....dp[i+1]+1,,,)那么可以得到两个递推式dp[i] = min(a[i], 之间的min+1)dp[i...
阅读全文
摘要:http://poj.org/problem?id=3744矩阵快速幂:利用DP的递推式就本题来说 dp[i] = p*dp[i-1] + (1-p)*dp[i-2]由于x非常大最大1亿,这样的话复杂度就为1亿所以这里可以用矩阵的思想[dp[i] dp[i-1] ] = [ dp[i-1] dp[...
阅读全文
摘要:/*贪心WA一发。。二分枚举加的数赛后发现直接暴力枚举1到1000也是可以的*//************************************************* Author :Powatr* Created Time :2015-8-30 0:58:45* Fi...
阅读全文
摘要:/*写搜索WA了。。赛后发现直接暴力不会超啊,,,*//************************************************* Author :Powatr* Created Time :2015-8-30 14:55:10* File Name ...
阅读全文
摘要:1.object 上帝类 所有父类的子类在每一个类中都隐藏有super() 最终父类都是指向object 类可以利用这个实现多态 instanceof2.内部类 顾名思义,即一个类里面的类,为了增加代码的简洁性,使一个功能可以被持续使用class A{ class B{ }}当然如果...
阅读全文
摘要:http://poj.org/problem?id=2096dp[i][j] 表示 已经侵入了i个子系统,已经拥有了j种类的期望状态转移方程 dp[i][j] = dp[i][j]*(i*j)/(n*s) + dp[i+1][j]*(n-i)*j/(n*s) + dp[i][j+1]*i*(s-j)...
阅读全文
摘要:不能处理有环的图void SPFA(){ memset(vis, false, sizeof(vis)); vis[1] = true; for(int i = 1; i d[u] + w){ d[v] = d[u] + w; ...
阅读全文
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=5294SPFA:Bellman_Ford的队列优化算法无法处理带负环的图复杂度O(kE) k #include #include #include #include #include #include #inclu...
阅读全文
摘要:java语言的三个特征封装,继承,以及多态多态的概念:一个对象能被多个类(必须有继承关系)所定义Cat cat = new Animal也能Cat cat = new CatAniamal 是 Cat 的父类 class Cat extends Animal这里就有个区分对于非静态量,编译看左边这个...
阅读全文
摘要:再说继承:继承是类与类之间的一种关系,对于一个参数,在继承之后,会在子类中隐藏自动的加上一个代码块super()关键字:super 原本学了一个this关键字,在复习一下,this关键字是该类直接调用对象进行操作,而super也差不多,只是调用的是父类为什么要有这样一个代码块super()/this...
阅读全文
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=4336转自http://www.cnblogs.com/zhj5chengfeng/archive/2013/03/02/2939601.html做法分析由于卡片最多只有 20 种,使用状态压缩,用 0 表示这种卡...
阅读全文
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=4334二分T。。/************************************************* Author :Powatr* Created Time :2015-8-25 ...
阅读全文
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=4324/*搜索一个三角形,用vector+vis来减少复杂度*//************************************************* Author :Powatr* C...
阅读全文
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=4325/*upper_bound 找大于a[i]的最近的下标lower_bound 找大于等于a[i]的最近的下标1 2 4 4 4 5 6 ...l r l r l l l ...此时q = 4upper_bou...
阅读全文
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=4320/*公式:两个进制能相互转化,那么这两个进制的最小因数相同*//************************************************* Author :Powatr*...
阅读全文
摘要:http://poj.org/problem?id=1273最大流算法:一张图有一个源点一个汇点,中间有很多要经过的点,点与点之间有最大流量的限制,问从源点到汇点的最大每秒流量是多少加入了残余网络和增广路这两个概念残余网络:是对于一次处理之后得到得剩下的图增广路:对于u到i的的流量我少了x容量那么i...
阅读全文
摘要:单例模式:1.当只要求操作同一个对象时,只new一个对象,这个对象在类当中实现2.在这个类中只打开一个口,对于要传到对象的数据,静态私有化。静态:因为静态常量只能用于静态,不能用于非静态。私有:减少权限样例class Single{ private Single(){} private ...
阅读全文
摘要:http://acm.fzu.edu.cn/problem.php?pid=2141/*大意:把一张图分成一个二分图,使得任意相邻的顶点不在同一个集合里面,*//************************************************* Author :Powa...
阅读全文
摘要:参考博客——http://blog.finaltheory.info/algorithm/Chairman-Tree.html#主席数是一种离线树,用来查询l到r之间的第k最大/最小值的数据结构是一种函数式编程思想,即不断赋值,更新状态1.建树我们对于每一个节点都建一颗线段树,因为对于每一个节点建树...
阅读全文
摘要:简单BFShttp://acm.fzu.edu.cn/problem.php?pid=2150/************************************************* Author :Powatr* Created Time :2015-8-23 12:3...
阅读全文
摘要:http://acm.fzu.edu.cn/problem.php?pid=2148 /************************************************* Author :Powatr* Created Time :2015-8-23 18:28:5...
阅读全文
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=5418/*模板题先用floeyed处理*//************************************************* Author :Powatr* Created Time...
阅读全文
摘要:逆元 inv应用于取模运算中加法 (a + b) % p = a % p + b % p;减法 (a - b) % p = a % p - b % p;乘法 (a * b) % p = a % p * b % p;但是除法(a / b) % p :a * b % p = c;已知 b, c, p 求...
阅读全文
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=5414/************************************************* Author :Powatr* Created Time :2015-8-21 10:45...
阅读全文
摘要:成员变量(全局变量)存放在堆里面,占用内存,初始化为0局部变量 不占用内存,存放在栈里面,没有初始值关键字 :public, private 关键字权限的意思 在一个类里面,如果主函数不调用类里面的东西,那么用private把它私有化,保证封装性,只留一个入口static 静态存储变量是除了创建对象...
阅读全文
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=5410/*先01背包一下再完全背包一下*//************************************************* Author :Powatr* Created Time...
阅读全文
摘要:System.out.print()最后输出没有回车System.out.println()最后输出有回车System.out.print()输出格式是拼接型的比如输出1+2=3System.out.print(1+"+"+2+"="+3);形参的三种形式int,double/float,boole...
阅读全文
摘要:http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=3827/*输出用f*//************************************************* Author :Powatr* Cre...
阅读全文
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=4911/*裸题有重复的不能用树状数组!!!!sort的时候会出错*//************************************************* Author :Powatr*...
阅读全文
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=5400/************************************************* Author :Powatr* Created Time :2015-8-18 13:00...
阅读全文
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=5396/*题目大意:给你一些表达式,问你不考虑乘除优先级,问所有可能性之和为多少比方说 (1+2)+3 1+(2+3) 算不同定义dp[i][j] 表示从i到j之和令k为两个表达式之间的符号如果k为* 状态转...
阅读全文
摘要:class test//class 类{ public static void main (String[] args) { System.out.println("Hello world\n"); }}hellow world!!!一个类相当于一个class文件,如...
阅读全文
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=5399/*先特判有重复数的情况,如果有就输出-1如果全是数字那么就判是否符合条件剩下的就是m!的(cout-1)次*//***********************************************...
阅读全文
摘要:http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=3829/*题意:要求变成合法的串需要操作多少次有两个操作1.添加 2.交换先扫一遍得到肯定要添的数字从前往后,如果发现有数字n++,如果n#include #include...
阅读全文
摘要:只要文件在%SystemRoot%\system32\ 下calc 打开计算器mspaint 打开画图notepad 打开记事本winmine 扫雷http://wenku.baidu.com/link?url=1_fVv8yM4XJAfbiq1lShVYmRJhWXjQZj4HdvMR1ULoj4...
阅读全文
摘要:DOS 命令c: 切换盘符dir列出当前目录下的所有文件md 创建一个目录rd 删除一个目录cd.. 退一级cd\ 返回根目录 反斜线exit 退出 dos命令行cd\查找路径进入 斜线del 删除文件(也可以删除目录下的所有文件)JAVA 由SUN(stanford University Ne...
阅读全文
摘要:http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=3822/*dp[i][j][k]定义为覆盖了i行j列用了>=k个棋子的概率状态转移方程dp[i][j][k] = dp[i-1][j][k-1]*1.0*(j*(n-i+1))...
阅读全文
摘要:转自http://blog.csdn.net/mxymxy1994mxy/article/details/47679971#include#include#include#includeusing namespace std;//C++扩栈#pragma comment(linker, "/STAC...
阅读全文
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=5380/*双端队列题意:加油问题,从起始到终点。,每走一步需要消耗1L油,中途可以买卖油,有一个最大油量,问你到达终点的最少花费是多少用一个双端队列维护*//****************************...
阅读全文
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=5392/*先把循环长度提取出来,再求这些长度的最小公倍数把质因数都分解出来,每个质因数取最大所有数之积就是最小公倍数*//**********************************************...
阅读全文
摘要:/************************************************* Author :Powatr* Created Time :2015-8-17 10:52:03* File Name :欧式筛法.cpp *****************...
阅读全文
摘要:http://poj.org/problem?id=2689/*区间筛法适用于L, R范围比较大,但是区间长度较小时套个模板然后取出最小最大就可以*//************************************************* Author :Powatr* C...
阅读全文
摘要:1 : 22 : 43 : 84 : 165 : 326 : 647 : 1288 : 2569 : 51210 : 102411 : 204812 : 409613 : 819214 : 1638415 : 3276816 : 6553617 : 13107218 : 26214419 : 524...
阅读全文
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=5391/*求(n-1)!%n先打个表发现与素数有关,而且4特判,然后只要尽可能降低复杂度就行*//************************************************* Author ...
阅读全文
摘要:http://codeforces.com/problemset/problem/446/A/*贪心,开前缀后缀,枚举,每个i*//************************************************* Author :Powatr* Created Tim...
阅读全文
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=5384/*AC自动机是用来求多字符串匹配问题,所需要掌握的基础是KMP和trie对匹配子串建立一棵trie树,对这棵树进行KMP匹配*//**************************************...
阅读全文
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=1251/*模板题,c表示最长后缀串的编号,如果后面加入的与前面的字符一直相同,那么不会产生新的推荐http://www.cnblogs.com/yym2013/p/3780621.htmlhttp://blog.c...
阅读全文
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=5389/*数相加超过两位数个十位相加等价于所有数相加Mod9大意: 有两扇门,n个人,要使得这些人全部进去这两扇门,进去的条件是两个sum_group模9为门上的数,问有多少种方案定义 dp[i][j] 已经选了i...
阅读全文
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=5372/*要求有多少线段被现在加进去的线段完全覆盖,所求即左端点比当前加进去的线段大的减去右端点比当前加进去的线段大的,就是覆盖的线段树用两个树状数组来更新左端点和右端点的值跟求逆序数那道题目一样,进行排序,二分得...
阅读全文
摘要:http://poj.org/problem?id=2352模板/************************************************* Author :Powatr* Created Time :2015-8-13 16:18:10* File Name...
阅读全文
摘要:upper_bound 大于找上界lower_bound 大于等于找下界
阅读全文
摘要:原文地址 http://blog.sina.com.cn/s/blog_76b0cde40100t32r.html被2整除的数是偶数。被3整除的数必须各个位数上的数加起来为三的倍数,比如136,1+3+6=10不行,147=1+4+7=12,就可以。被5整除个位为0或者5.能被7整除的数的特征一个数...
阅读全文
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=5371/*先用Manacher算法得出最长回文子串,然后用set维护ans的值对所有回文的长度进行排序, 那么之后的点如果覆盖了最接近的点那么那么点肯定是覆盖了当前点,用二分得到最近不大于u的距离S.upper_b...
阅读全文
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=5233/*用map和set进行离散化,离散化就是对于大数据进行重新编号*//************************************************* Author :Powa...
阅读全文
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=5340/*Manacher算法:O(n) 实现最长回文子串算法实现:先向原字符串中插入一个原来串不存在的字符,一般用'#',再O(n)遍历一遍,用一个数组p[i]来记录以str[i]为中心的回文半径(注意str[i...
阅读全文
摘要:格雷值与二进制转化公式,G[i] = B[i]^B[i-1],二进制前面补0dp[i][j]定义为当前是第i个格雷值,值是j的和* Author :powatr* Created Time :2015-8-11 13:19:46* File Name :1007.cpp **...
阅读全文
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=5373/************************************************* Author :Powatr* Created Time :2015-8-12 9:23:...
阅读全文
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=5349/************************************************* Author :Powatr* Created Time :2015-8-9 19:37:...
阅读全文
摘要:http://poj.org/problem?id=1426/*暴力发现最大数目不超过19位,开unsigned long long 水过*//************************************************* Author :Powatr* Creat...
阅读全文
摘要:http://poj.org/problem?id=3279/*枚举第一行所有的状态,接下来的行都已经确定了,字典序最小输出 *//************************************************* Author :Powatr* Created Tim...
阅读全文
摘要:http://poj.org/problem?id=2251/*简单bfs,向六个方向拓展*//************************************************* Author :Powatr* Created Time :2015-8-9 9:23:...
阅读全文
摘要:Polycarp loves geometric progressions very much. Since he was only three years old, he loves only the progressions of length three. He also has a favo...
阅读全文
摘要:Berland National Library has recently been built in the capital of Berland. In addition, in the library you can take any of the collected works of Ber...
阅读全文
摘要:Problem DescriptionAs we all kown, MZL hates the endless loop deeply, and he commands you to solve this problem to end the loop.You are given an undir...
阅读全文
摘要:Problem DescriptionThere arensoda conveniently labeled by1,2,…,n. beta, their best friends, wants to invite some soda to go hiking. Thei-th soda will ...
阅读全文
摘要:set go= cin nu ts=4 sw=4 sts=4 noswapfile nobackup acd et cursorlineset backspace=eol,start,indentsyntax onset lines=90 columns=80map :!g++ -o2 -std=...
阅读全文
摘要:#gragma comment(linker, "/STACK:1024000000,1024000000")
阅读全文
摘要:MZL loves xor very much.Now he gets an array A.The length of A is n.He wants to know the xor of all (Ai+Aj)(1≤i,j≤n)The xor of an array B is defined a...
阅读全文
摘要:DescriptionIn the Fibonacci integer sequence,F0= 0,F1= 1, andFn=Fn− 1+Fn− 2forn≥ 2. For example, the first ten terms of the Fibonacci sequence are:0, ...
阅读全文
摘要:/************************************************Author :powatrCreated Time :2015-8-5 21:06:30File Name :b.cpp****************************...
阅读全文
摘要:Watto, the owner of a spare parts store, has recently got an order for the mechanism that can process strings in a certain way. Initially the memory o...
阅读全文
摘要:The cows are journeying north to Thunder Bay in Canada to gain cultural enrichment and enjoy a vacation on the sunny shores of Lake Superior. Bessie, ...
阅读全文
摘要:A lot of battleships of evil are arranged in a line before the battle. Our commander decides to use our secret weapon to eliminate the battleships. Ea...
阅读全文
摘要:There is an integeraandnintegersb1,…,bn. After selecting some numbers fromb1,…,bnin any order, sayc1,…,cr, we want to make sure thatamodc1modc2mod…mod...
阅读全文
摘要:You have two friends. You want to present each of them several positive integers. You want to presentcnt1numbers to the first friend andcnt2numbers to...
阅读全文
摘要:You haveNintegers,A1,A2, ... ,AN. You need to deal with two kinds of operations. One type of operation is to add some given number to each number in a...
阅读全文
摘要:At the entrance to the university, there is a huge rectangular billboard of size h*w (h is its height and w is its width). The board is the place wher...
阅读全文
摘要:Soda has a bipartite graph withnvertices andmundirected edges. Now he wants to make the graph become a complete bipartite graph with most edges by add...
阅读全文
摘要:Mr. Hdu is interested in Greatest Common Divisor (GCD). He wants to find more and more interesting things about GCD. Today He comes up with Range Grea...
阅读全文
摘要:Luke wants to upgrade his home computer network from 10mbs to 100mbs. His existing network uses 10base2 (coaxial) cables that allow you to connect any...
阅读全文
摘要:There are N point on X-axis . Miaomiao would like to cover them ALL by using segments with same length.There are 2 limits:1.A point is convered if the...
阅读全文
摘要:Josephina is a clever girl and addicted to Machine Learning recently. Shepays much attention to a method called Linear Discriminant Analysis, whichhas...
阅读全文
摘要:Farmer John has built a new long barn, with N (2 #include #include using namespace std;const int inf = 0x3f3f3f3f;const int MAX = 1e6 + 10;int n, m;in...
阅读全文
摘要:Language:Cable masterTime Limit:1000MSMemory Limit:10000KTotal Submissions:29971Accepted:6349DescriptionInhabitants of the Wonderland have decided to ...
阅读全文
摘要:Give you three sequences of numbers A, B, C, then we give you a number X. Now you need to calculate if you can find the three numbers Ai, Bj, Ck, whic...
阅读全文
摘要:Every year the cows hold an event featuring a peculiar version of hopscotch that involves carefully jumping from rock to rock in a river. The exciteme...
阅读全文
摘要:The WHU ACM Team has a big cup, with which every member drinks water. Now, we know the volume of the water in the cup, can you tell us it height?The r...
阅读全文
摘要:Problem DescriptionIn ann∗mmaze, the right-bottom corner is the exit (position(n,m)is the exit). In every position of this maze, there is either a0or ...
阅读全文

浙公网安备 33010602011771号