自定义博客皮肤VIP专享

*博客头图:

格式为PNG、JPG,宽度*高度大于1920*100像素,不超过2MB,主视觉建议放在右侧,请参照线上博客头图

请上传大于1920*100像素的图片!

博客底图:

图片格式为PNG、JPG,不超过1MB,可上下左右平铺至整个背景

栏目图:

图片格式为PNG、JPG,图片宽度*高度为300*38像素,不超过0.5MB

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(18)
  • 问答 (1)
  • 收藏
  • 关注

原创 深度优先搜索 DFS

类似于树的先根遍历,对每一个可能的分支路径深入到不能再深入为止,而且每个结点只能访问一次。两种实现方式:1、利用栈实现:while(栈非空){        弹出栈顶元素,并标记已访问;        遍历栈顶元素的所有未访问过的相邻结点,并入栈;}2、利用递归实现:DFS(n){if(找到解||走不下去 ){...return;}...dfs(n+1);}例题:方格填数 如下的10个格子 ...

2018-03-31 17:11:47 271

原创 动态规划--背包问题

1、01背包问题将质量为wi、价值为vi的n种物品,每种物品只有一个,放入最大承重为m的背包中,求背包所能得到的最大价值。动态转移方程:f[i][j]=max(f[i-1][j],f[i-1][j-wi]+vi);f[i][j]的含义是从前i种物品中取物品放入最大承重为j的背包中,所能得到的最大价值。它等于下述两种情况的最大值:   1、忽略第i种物品,从前i-1种物品中取物品放入最大承重为j的背...

2018-03-30 11:40:11 169

原创 枚举法(一)

枚举法 主要需要尽量减小枚举的次数,排除不必要的枚举。可通过事先排好顺序等方法。POJ 1681Painter's ProblemDescriptionThere is a square wall which is made of n*n small square bricks. Some bricks are white while some bricks are yellow. Bob is ...

2018-03-19 13:00:04 1293

原创 4.9 矩阵(数组应用的典型范例3)

zoj 1949Error CorrectionA boolean matrix has the parity property when each row and each column has an even sum, i.e. contains an even number of bits which are set. Here's a 4 x 4 matrix which has the ...

2018-03-13 23:03:51 259

原创 4.7/4.8 多项式的表示与处理(数组应用的典型范例2)

多项式存储的两种方式:1、数值数组 数组的下标与多项式的项的指数相关,数组长度取决于多项式的最高次幂。2、结构数组 数组下标为项序号而非指数值,a[i].coef 当前项的系数 以及a[i].exp 当前项的指数。数组长度是多项式的实际长度。ZOJ 1720Polynomial ShowdownGiven the coefficients of a polynomial from degree 8...

2018-03-12 23:16:33 661

原创 4.6 高精度

ZOJ 2001Adding Reversed NumbersThe Antique Comedians of Malidinesia prefer comedies to tragedies. Unfortunately, most of the ancient plays are tragedies. Therefore the dramatic advisor of ACM has deci...

2018-03-12 12:48:06 147

原创 4.3/4.4/4.5/4.6 高精度(数组应用的典型范例1)

高精度数主要指超出标准数据类型所能表示的数,比如两个200位数相加减。而处理高精度数可以使用数组存储,然后再进行计算。一、高精度数的存储将数字反向存储在数组中,即数字的个位数存储在数组下标为0处,依次类推。for(i=0;i<s.length;i++){num[i]=s[s.length-n-i]-'0';}c语言:char s1[50];    c1=s1;scanf("%s",c1); ...

2018-03-11 23:16:30 174

原创 4.1/4.2 应用直接存取类线性表编程

ZOJ 2420CalendarA calendar is a system for measuring time, from hours and minutes, to months and days, and finally toyears and centuries. The terms of hour, day, month, year and century are all units ...

2018-03-10 13:44:07 258

原创 八皇后问题总结

3种方法解决:1、经典递归回溯#include <stdio.h>#include <math.h>int num=0;int x[8];int main(){    queen(0);    printf("%d",num);    return 0;}void queen(int row){if(row>=8){    num++;    return ;}int...

2018-03-10 09:25:52 780

原创 3.4/3.5 The Sultan's Successors

HDOJ 1642Problem Description The Sultan of Nubia has no children, so she has decided that the country will be split into up to k separate parts on her death and each part will be inherited by whoever ...

2018-03-09 21:08:10 342

原创 昨日知识总结--next nextLine nextInt

next--读取本行数据,到空格或者换行符之前结束,游标还在本行。nextline--读取本行剩余数据,到换行符结束,游标到下一行。nextInt--读取整型数据,游标在本行。例如:6 9....#......#..............................#@...#.#..#.存到两个变量以及一个char[][]数组中,java:int w = cin.next...

2018-03-07 11:26:09 277

原创 昨日知识总结--static关键字

1、static关键字昨日使用到static是java中要在main方法中调用递归方法,main为静态方法,所以调用的递归方法也要设置为静态方法。静态方法: 使方法不再依赖与对象,而是依赖于类本身,方便在没有创建对象的时候访问。this.function(),function()为静态方法的话,则上述表述错误,因为静态方法不依赖于对象,而是依赖于类本身,不依赖于对象,因此不存在this。静态方法只...

2018-03-07 08:41:56 239

原创 3.3 回溯法

poj 1979Red and BlackDescriptionThere is a rectangular room, covered with square tiles. Each tile is colored either red or black. A man is standing on a black tile. From a tile, he can move

2018-03-06 23:15:47 165

原创 3.1/3.2 递归与回溯法的编程实验

ZOJ 2172Symmetric OrderIn your job at Albatross Circus Management (yes, it's run by a bunch of clowns), you have just finished writing a program whose output is a list of names in nondescendin

2018-03-06 23:10:42 325

原创 2.3 构造法模拟

import java.util.Scanner;//uva 11000public class BEE {    public static void main(String[] args) {        Scanner cin = new Scanner(System.in);        int year = cin.nextInt();        whil

2018-03-06 23:06:08 177

原创 2.2 筛选法模拟

Self NumbersDescriptionIn 1949 the Indian mathematician D.R. Kaprekar discovered a class of numbers called self-numbers. For any positive integer n, define d(n) to be n plus the sum of the dig

2018-03-05 22:51:29 264

原创 2.1 简单模拟的编程实验

Speed LimitBill and Ted are taking a road trip. But the odometer in their car is broken, so they don't know how many miles they have driven. Fortunately, Bill has a working stopwatch, so they can

2018-03-05 22:39:44 357

原创 1.5/1.6 使用二分法提高计算时效

POJ 1003HangoverDescriptionHow far can you make a stack of cards overhang a table? If you have one card, you can create a maximum overhang of half a card length. (We're assuming that the car

2018-03-05 22:29:52 144

空空如也

TA创建的收藏夹 TA关注的收藏夹

TA关注的人

提示
确定要删除当前文章?
取消 删除