- 博客(73)
- 收藏
- 关注
转载 欢迎使用优快云-markdown编辑器
常见的几种命名规则Hungarian(匈牙利命名法)基本原则是:变量名=属性+类型+对象描述。 匈牙利命名法通过在变量名前面加上相应的小写字母的符号标识作为前缀, 标识出变量的作用域, 类型等。前缀之后的是 首字母大写的一个单词或多个单词组合,该单词要指明变量的用途。 常用的类型前缀有: 前缀 说明 n 整型和位域变量(number)
2016-03-12 21:28:19
389
转载 莫比乌斯反演
莫比乌斯反演在数论中占有重要的地位,许多情况下能大大简化运算。那么我们先来认识莫比乌斯反演公式。 定理:和是定义在非负整数集合上的两个函数,并且满足条件,那么我们得到结论 在上面的公式中有一个函数,它的定义如下: (1)若,那么 (2)若,均为互异素数,那么 (3)其它情况下 对于函数,它有如下的常见性质:
2015-10-01 08:49:11
480
原创 我的模板
#include#include#include#include#include#includeusing namespace std;typedef long long LL;const int inf = 0x3f3f3f3f;const int N = 420, M = N * N;struct EG{ int u, v, cap; EG() {}
2015-08-26 23:43:40
429
转载 网络流(最小割)问题中的基础构图及分析方法小结
一,名词定义 割:流网络图G=(V,E)的一个划分,记作[S,T],将点集[V]划分为S和T两部分,且使得s属于S,t属于T,S+T=V。 最小割:一个网络的最小割也就是该网络中容量最小的割。 最大流最小割定理:流网络图G=(V,E)的最大流大小等于其最小割容量。二,存在固定模型的最小割问题构图方法及举例 1-二分图的最小点权覆盖集算法 定义:
2015-08-25 21:46:59
2603
原创 Codeforces Round #Pi (Div. 2)
A. Lineland Mailtime limit per test3 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputAll cities of Lineland are located on the Ox coordin
2015-08-17 16:33:09
835
转载 Treap
Treap是一棵二叉搜索树,只是每个节点多了一个优先级fix,对于每个节点,该节点的优先级小于等于其所有孩子的优先级。当然,引入优先级fix的目的就是防止BST退化成一条链,从而影响查找效率。 所以,这样看来就是:Treap中对于节点的关键字key来说,它是一棵二叉搜索树,而对于fix来说,它是一个最小堆,所以Treap可以看成是Tree+Heap,只是这里的Heap不一定是完全二
2015-08-05 17:32:55
395
原创 hdu 3473 Minimum Sum
Problem DescriptionYou are given N positive integers, denoted as x0, x1 ... xN-1. Then give you some intervals [l, r]. For each interval, you need to find a number x to make as small as possible!
2015-07-29 18:17:03
481
原创 hdu 2665 Kth number
Problem DescriptionGive you a sequence and ask you the kth big number of a inteval. InputThe first line is the number of the test cases. For each test case, the first line contain two inte
2015-07-29 18:04:57
318
原创 母函数
一、普通母函数 在数学中,某个序列的母函数是一种形式幂级数,每一项的系数都可以提供这个序列的一些信息。母函数可以分为很多种,包括普通母函数、指数母函数、L级数、贝尔级数和狄利克雷级数。 在研究母函数之前,先来看一个多项式乘法 (1+a1x)(1+a2x)...(1+anx) = 1+(a1+a2+...an)x+(a1a2+a1a3+...+a(n-1)an)x
2015-07-27 18:30:41
526
原创 排列组合
排列组合1.1 排列与组合排列数:n个不同物体不重复地取出r个做排列的方法数A(n,r)=P(n,r)。组合数:n个不同物体不重复地取出r个做组合的方法数C(n,r)。性质: C(n,r)=C(n,n-r) C(n,k)=C(n-1,k)+C(n-1,k-1) C(n,k)C(k,r)=C(n,r)C(n-r,k-r),(k≥r)1.2 常见
2015-07-27 10:24:39
404
原创 hdu 5245 Joyful
Problem DescriptionSakura has a very magical tool to paint walls. One day, kAc asked Sakura to paint a wall that looks like anM×N matrix. The wall has M×N squares in all. In the whole problem
2015-06-11 21:31:26
363
原创 后缀数组模板
int sa[maxn], t1[maxn], t2[maxn], c[maxn];void build(int*r, int *sa, int n, int m){ int *x = t1, *y = t2, i, k; for(i=0; i<m; i++) c[i] = 0; for(i=0; i<n; i++) c[x[i] = r[i]]++; for(
2015-04-29 15:43:45
358
原创 中南大学第九届大学生程序设计竞赛网络预选赛
A 最多的数字Description数字的每一位都由0~9组成,现在给出一个数,问你它所有位数中使用哪个数字最多。Input输入包含多个测试实例,每行为一个数字(所有数据小于10的1000次方)。Output每一行对应一个要求的答案。(答案为0~9之间的一个数,如果有一样多的情况,输出最小的数字)Sample Input1234567
2015-04-19 22:22:52
1287
转载 UVA11419【输出最小点覆盖】
转自: http://www.matrix67.com/blog/archives/116 二分图最大匹配的König定理及其证明 本文将是这一系列里最短的一篇,因为我只打算把König定理证了,其它的废话一概没有。 以下五个问题我可能会在以后的文章里说,如果你现在很想知道的话,网上去找找答案: 1. 什么是二分图; 2. 什么是二分图的匹配; 3. 什么是匈牙利算法;
2015-03-21 22:53:00
581
原创 最短路算法总结
//单源最短路之Dijkstra算法/*朴素的dijkstra算法,复杂度为O(V²);*/const int INF = INT_MAX;int d[N],vis[N];int w[N][N];void dijkstra(int s, int n){ memset(vis,0,sizeof(vis)); for(int i=1; i<=n; i++) d[i] =
2015-03-21 15:15:35
505
原创 UVA - 1146 Now or later
As you must have experienced, instead of landing immediately, anaircraft sometimes waits in a holding loop close to the runway. Thisholding mechanism is required by air traffic controllers to spaceapa
2015-03-21 12:51:33
598
原创 UVA 11324 The Largest Clique
Problem B: The Largest CliqueGiven a directed graph G, consider the following transformation. First, create a new graphT(G) to have the same vertex set asG. Create a directed edge betweentwo ver
2015-03-21 10:59:38
364
原创 UVA1108 HDU3844 Mining Your Own Business
Mining Your Own BusinessTime Limit: 6000/3000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 1583 Accepted Submission(s): 255Problem DescriptionJohn D
2015-03-21 09:45:50
677
原创 最大流之EK算法模板(小白皮)
直接上代码:/** 每次直接用BFS 找最短增广路,时间复杂度为O(VE²) */int maxflow(int s, int t, int n){ queueq; memset(flow,0,sizeof(flow)); int f = 0; while(1) { memset(a,0,sizeof(a)); a[s] =
2015-03-16 20:13:37
391
转载 Java图形化界面设计——布局管理器之null布局(空布局)
一般容器都有默认布局方式,但是有时候需要精确指定各个组建的大小和位置,就需要用到空布局。 操作方法:1) 首先利用setLayout(null)语句将容器的布局设置为null布局(空布局)。2) 再调用组件的setBounds(int x, int y, int width,int height)方法设置组件在容器中的大小和位置,单位均为像素
2014-12-30 16:42:23
1276
转载 Java图形化界面设计——布局管理器之CardLayout(卡片布局)
卡片布局能够让多个组件共享同一个显示空间,共享空间的组件之间的关系就像一叠牌,组件叠在一起,初始时显示该空间中第一个添加的组件,通过CardLayout类提供的方法可以切换该空间中显示的组件。 1、 CardLayout类的常用构造函数及方法 2、 使用CardLayout类提供的方法可以切换显示该空间中的组件 方法一步骤:(1) 定义使用卡片布
2014-12-30 16:39:13
6427
1
转载 Java图形化界面设计——布局管理器之GridLayout(网格布局)
网格布局特点:l 使容器中的各组件呈M行×N列的网格状分布。l 网格每列宽度相同,等于容器的宽度除以网格的列数。l 网格每行高度相同,等于容器的高度除以网格的行数。l 各组件的排列方式为:从上到下,从左到右。l 组件放入容器的次序决定了它在容器中的位置。l 容器大小改变时,组件的相对位置不变,大小会改变。l 设置网格布局行数和列数时,行数或者列数可以有一个
2014-12-30 16:36:54
1042
转载 Java图形化界面设计——布局管理器之BorderLayout(边界布局)
边界布局管理器把容器的的布局分为五个位置:CENTER、EAST、WEST、NORTH、SOUTH。依次对应为:上北(NORTH)、下南(SOUTH)、左西(WEST)、右东(EAST),中(CENTER),如下图所示。特征:l 可以把组件放在这五个位置的任意一个,如果未指定位置,则缺省的位置是CENTER。l 南、北位置控件各占据一行,控件宽度将自动布满整行。东、西和中间
2014-12-30 16:34:32
554
转载 Java图形化界面设计——布局管理器之FlowLayout(流式布局)
前文讲解了JFrame、JPanel,其中已经涉及到了空布局的使用。Java虽然可以以像素为单位对组件进行精确的定位,但是其在不同的系统中将会有一定的显示差异,使得显示效果不尽相同,为此java提供了布局管理器,以使编写的图形界面具有良好的平台无关性。 注意:所有的布局管理器均是针对容器来使用的,包括顶层容器和中间容器。 一、布局管理器所属类包
2014-12-30 16:30:39
928
转载 Java图形化界面设计——中间容器(Jpanel)
上一篇讲解了Jframe顶层容器,例子中生成了一个空的窗体,在实际编程过程中,一般很少将文本框、按钮等组件直接放在顶层容器中进行布局,大多数时候是通过布局管理器结合中间容器对组件进行布局设置。 1、 将组件添加到JFrame中方式之一: frame.getContentPane().add(childComponent)用getContentPane()方法获得J
2014-12-30 16:26:59
719
转载 Java图形化界面设计——容器(JFrame)
程序是为了方便用户使用的,因此实现图形化界面的程序编写是所有编程语言发展的必然趋势,在命令提示符下运行的程序可以让我们了解java程序的基本知识体系结构,现在就进入java图形化界面编程。 一、Java基本类(JFC)Java基本类(“Java FoundationClasses”,JFC),由一些软件包组成。这些软件包主要包括下面一些应用程序接口(API): ·抽象窗口工具集(
2014-12-30 15:47:59
921
转载 JFrame中setDefaultCloseOperation的参数含义
实例1:一个空的java窗口// JFrameDemo1.javaimport javax.swing.*; //使用Swing类,必须引入Swing包public class JFrameDemo1 { public static void main(String args[]) { // 定义一个窗体对象f,窗体名称为"一个简单窗口" JFrame f = new JFr
2014-12-30 15:39:22
1108
转载 贪吃蛇实现--Java
package cn.sun;import java.awt.*;import java.awt.event.*;import javax.swing.*;import java.util.*;//=============================================//Main Class//=================================
2014-12-30 14:07:12
521
原创 面向对象一
类的初始化过程: Student s = new Student();在内存中做了哪些事情? •加载Student.class文件进内存 •在栈内存为s开辟空间 •在堆内存为学生对象开辟空间 •对学生对象的成员变量进行默认初始化 •对学生对象的成员变量进行显示初始化 •通过构造方法对学生对象
2014-12-26 11:00:32
355
原创 poj 1201 Intervals
DescriptionYou are given n closed, integer intervals [ai, bi] and n integers c1, ..., cn.Write a program that: reads the number of intervals, their end points and integers c1, ..., cn from the
2014-11-20 21:50:46
330
原创 poj 1990 - MooFest
DescriptionEvery year, Farmer John's N (1 <= N <= 20,000) cows attend "MooFest",a social gathering of cows from around the world. MooFest involves a variety of events including haybale stacking, fen
2014-11-19 17:05:36
380
原创 poj 2991-Crane
DescriptionACM has bought a new crane (crane -- jeřáb) . The crane consists of n segments of various lengths, connected by flexible joints. The end of the i-th segment is joined to the beginning of
2014-11-19 11:03:41
373
原创 CodeForces 383C Propagating tree
DescriptionIahub likes trees very much. Recently he discovered an interesting tree named propagating tree. The tree consists ofn nodes numbered from 1 to n, each node i having an initial val
2014-11-17 22:08:28
419
原创 CodeForces 377B Preparing for the Contest
DescriptionSoon there will be held the world's largest programming contest, but the testing system still hasm bugs. The contest organizer, a well-known university, has no choice but to attract u
2014-11-17 17:17:13
623
原创 CodeForces 482B Interesting Array
nteresting Arraytime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputWe'll call an array of n non-negative integersa[1], a
2014-11-17 13:52:22
449
原创 CodeForces 319B Psychos in a Line
Psychos in a Linetime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputThere are n psychos standing in a line. Each psycho is
2014-11-17 13:23:00
766
转载 CodeForces 148D Bag of mice
DescriptionThe dragon and the princess are arguing about what to do on the New Year's Eve. The dragon suggests flying to the mountains to watch fairies dancing in the moonlight, while the princess
2014-11-14 21:54:18
381
原创 poj 2151 Check the difficulty of problems
Time Limit: 2000MS Memory Limit: 65536KTotal Submissions: 5109 Accepted: 2261DescriptionOrganizing a programming contest is not an easy job. To avoid making the problems too di
2014-11-14 21:49:40
317
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人