自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(15)
  • 收藏
  • 关注

原创 快速幂 LightOJ 1282 - Leading and Trailing

题意就是求n的k次方的前三位和后三位 - 后三位快速幂取模就行。 - 前三位,首先pow(n,k)=pow(10,k*lg(n)),此时可以看出pow(n,k)的值的位数是由k *lg(n)的整数部分决定,而值是由其小数部分决定,因此只取前三位的话让k *lg(n)的小数部分在加上2即可,然后再将其转化为整数形式,舍去后面的小数。 即pow(10,2+fmod(k *log10(n),1))

2017-08-22 20:56:38 221

原创 欧拉常数(调和级数求和) Harmonic Number

In mathematics, the nth harmonic number is the sum of the reciprocals of the first n natural numbers: In this problem, you are given n, you have to find Hn. InputInput starts with an integer T

2017-08-21 21:30:50 8563

原创 素数筛 LightOJ - 1259 Goldbach`s Conjecture

Goldbach's conjecture is one of the oldest unsolved problems in number theory and in all of mathematics. It states:Every even integer, greater than 2, can be expressed as the sum of two primes [1].Now

2017-08-21 21:24:44 185

原创 dijskstra算法及其队列优化,spfa,floyd Til the Cows Come Home POJ - 2387

Description Bessie is out in the field and wants to get back to the barn to get as much sleep as possible before Farmer John wakes her for the morning milking. Bessie needs her beauty sleep, so she wa

2017-08-18 20:35:37 369

原创 区间dp uva 10003 - Cutting Sticks

题意就是给出棍子的长度和n个切点,让你把它切成n+1段,每次切时花费价值为此时棍子的长度,问怎样切才能使最终花费最少。 区间dp,就是指一整段区间的最优值可以由其中几段小区间的最优值来决定,因此次类问题一般都是从小到大枚举区间的大小,然后再求每一个该大小的区间的最优值,最终得到整个区间的最优值。#include<iostream> #include <algorithm> #include <cs

2017-08-18 20:30:31 227

原创 双调欧几里得旅行商问题 UVA 1347 Tour

题目:https://odzkskevi.qnssl.com/f85205c68ae5f131a579c799f71b7b69?v=1502173334 旅行商问题描述:平面上n个点,确定一条连接各点的最短闭合旅程。这个解的一般形式为NP的(在多项式时间内可以求出)J.L. Bentley 建议通过只考虑双调旅程(bitonictour)来简化问题,这种旅程即为从最左点开始,严格地从左到右直至最右

2017-08-16 21:06:20 213

原创 Floyd+Bellman-ford求正环 hdu1317 XYZZY

Problem Description It has recently been discovered how to run open-source software on the Y-Crate gaming device. A number of enterprising designers have developed Advent-style games for deployment on

2017-08-10 16:34:04 266

原创 Kruskal+二进制枚举 POJ 2784 Buy or Build

题目:https://odzkskevi.qnssl.com/95fc8c37ba05359d81df6779e817c236?v=1501937229因为q很小,所以直接枚举所有的方案就行。 首先求不用方案时的最小生成树,然后每次枚举方案时只需考虑初次最小生成树中的边就可以,如果每次都用所有边会tle。 感觉自己写的又长又蠢。。。 二进制枚举for(int i=0;i<(1<<q);i++)

2017-08-10 10:46:21 221

原创 最小生成树kruskal POJ 3522 Slim Span

题目:https://odzkskevi.qnssl.com/8e16f8701018d0e3529ac3ca319e1f67?v=1502277241 最简单的kruskal,主要参考紫书代码 kruskal算法就是先给边按权值大小排序,然后从小到大遍历,用并查集判断边上的两个点是否在同一集合,如果不是的话将其添加进去,直到所有的点都加入到集合中。#include <iostream> #in

2017-08-10 10:39:25 205

原创 LCS Common Subsequence

A subsequence of a given sequence is the given sequence with some elements (possible none) left out. Given a sequence X = #include <iostream> #include <algorithm> #include <cstring> using namespace std

2017-08-08 19:23:15 222

原创 01trie树 HDU 5536Chip Factory

Problem Description John is a manager of a CPU chip factory, the factory produces lots of chips everyday. To manage large amounts of products, every processor has a serial number. More specifically, t

2017-08-08 18:50:56 183

原创 trie树 POJ 2503 Babelfish

DescriptionYou have just moved from Waterloo to a big city. The people here speak an incomprehensible dialect of a foreign language. Fortunately, you have a dictionary to help you understand them. Inp

2017-08-08 17:52:42 281

原创 最长回文子串 V2(Manacher算法)

回文串是指aba、abba、cccbccc、aaaa这种左右对称的字符串。 输入一个字符串Str,输出Str里最长回文子串的长度。 Input 输入Str(Str的长度 <= 100000) Output 输出最长回文子串的长度L。 Sample Inputdaabaac Sample Output5 #include <iostream> #include <cstring

2017-08-07 22:28:43 239

原创 KMP HDU 1686 Oulipo

The French author Georges Perec (1936–1982) once wrote a book, La disparition, without the letter 'e'. He was a member of the Oulipo group. A quote from the book: Tout avait Pair normal, mais tout s

2017-08-07 22:25:58 209

原创 多重背包 HDU 2844 Coins

多重背包可转化为01背包,首先将件数C二进制分解为多个件数的集合,这些件数可以组合成任意 小于等于C的数字,而且不会重复。 如7 7=111,可以分解为100,010,001,这三个数可以组合为任意小于等于7的数,而且每种组合都会得到不同的数。 13 13=1101,可以分解为0001,0010,0100,0110,前三个数可以组合成7以内的任意数,加上6就可以组合为任意大于6小于等

2017-08-03 18:54:12 229

空空如也

空空如也

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

TA关注的人

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