自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+

独钓门前月

欲买桂花同载酒,终不似,少年游

  • 博客(46)
  • 收藏
  • 关注

原创 POJ1804-Brainman 【逆序对归并排序】

考虑具有n个数的排列a[1],a[2],……,a[n],如果其中存在j,k,满足j < k 且a[j] > a[k] , 那么就称(a[j] , a[k] )是这个排列的一个逆序。一个排列含有逆序的个数称为这个排列的逆序数。例如排列 263451 含有8个逆序(2,1),(6,3),(6,4),(6,5),(6,1),(3,1),(4,1),(5,1),因此该排列的逆序数就是8。现...

2019-02-28 23:06:19 342

原创 POJ1485-Common Subsequence【最长公共子序列】

A subsequence of a given sequence is the given sequence with some elements (possible none) left out. Given a sequence X = < x1, x2, ..., xm > another sequence Z = < z1, z2, ..., zk > is a ...

2019-02-28 15:32:11 173

原创 CodeForces 1130C- Connect【BFS】

Alice lives on a flat planet that can be modeled as a square grid of sizen×nn×n, with rows and columns enumerated from11tonn. We represent the cell at the intersection of rowrrand columnccwith...

2019-02-28 15:06:54 757

原创 HDU1160-FatMouse's Speed【最长单调子序列】

FatMouse believes that the fatter a mouse is, the faster it runs. To disprove this, you want to take the data on a collection of mice and put as large a subset of this data as possible into a sequence...

2019-02-28 13:07:20 243

原创 POJ3784-Running Median 【对顶堆】

For this problem, you will write a program that reads in a sequence of 32-bit signed integers. After each odd-indexed value is read, output the median (middle value) of the elements received so far....

2019-02-27 12:55:41 179

原创 POJ2299-Ultra-QuickSort【归并排序】

In this problem, you have to analyze a particular sorting algorithm. The algorithm processes a sequence of n distinct integers by swapping two adjacent sequence elements until the sequence is sorted i...

2019-02-27 12:42:08 164

原创 CodeForcces 670C-Cinema 【排序+离散化】

题意:n个科学家去看电影,每个人只会一门语言,电影的声音和字幕是不同的语言,让你找到哪部电影听懂的最多(一样多时找看懂最多的)。思路:首先我们先进行离散化,然后统计掌握每门语言的人数,然后通过排序找到最优解。#include<set>#include<map>#include<cstdio>#include<cmath>#inclu...

2019-02-25 21:02:10 195

原创 POJ2018-Best Cow Fences【二分+前缀和】

Farmer John's farm consists of a long row of N (1 <= N <= 100,000)fields. Each field contains a certain number of cows, 1 <= ncows <= 2000. FJ wants to build a fence around a contiguous g...

2019-02-24 22:20:13 275

原创 前缀和与差分

一维前缀和就是s[i] = a[i] + a[i - 1],如果要求某个区间[l, r] 的和就是sum(l, r) = s[r] - s[l - 1]。差分差分数列定义为:B[1] = A[1], B[i] = A[i] - A[i - 1] (2<= i <= n)容易发现:差分序列B的前缀和就是原序列A,前缀和序列S的差分序列就是原序列A。二...

2019-02-20 19:04:03 254 2

原创 POJ3263-Tallest Cow【前缀和+技巧】

FJ's N (1 ≤ N ≤ 10,000) cows conveniently indexed 1..N are standing in a line. Each cow has a positive integer height (which is a bit of secret). You are told only the height H (1 ≤ H ≤ 1,000,000) of ...

2019-02-20 17:38:48 419

原创 BZOJ1218: [HNOI2003]激光炸弹【二维前缀和】

Description一种新型的激光炸弹,可以摧毁一个边长为R的正方形内的所有的目标。现在地图上有n(N<=10000)个目标,用整数Xi,Yi(其值在[0,5000])表示目标在地图上的位置,每个目标都有一个价值。激光炸弹的投放是通过卫星定位的,但其有一个缺点,就是其爆破范围,即那个边长为R的正方形的边必须和x,y轴平行。若目标位于爆破正方形的边上,该目标将不会被摧毁。 Input...

2019-02-20 11:09:09 162

原创 UVA11827-Maximum GCD【数论】

思路:这题比较简单,从头到尾比较一遍就行了,需要注意的就是输入方式,需要进行转换,将字符串转换成整数类型,另外答案最小是1,需要注意一下。#include<set>#include<map>#include<cstdio>#include<cmath>#include<queue>#include<vector&gt...

2019-02-19 22:06:04 162

原创 UVA10200-Prime Time【暴力、数论】

思路:首先我就否定了暴力判断是否是素数,然后又想着筛素数空间会爆,没想到最后还是暴力可以过,果然是暴力出奇迹。最后输出的时候会卡精度,wa的我莫名其妙的,这题也是有点坑#include<set>#include<map>#include<cstdio>#include<cmath>#include<queue>#inclu...

2019-02-19 16:45:39 176

原创 UVA540-Team Queue【队列】

思路:紫书上的例题,首先用map来存储每个人在哪个队,如果用数组的话也可以,但是花费的空间比较大,而且如果某个人序号比较大的话开不来那么大空间,所以用map很方便,之后用两个队列,一个是总队列,另一个是每个小组的队列,接下来我们模拟就行了。#include<set>#include<map>#include<cstdio>#include<cm...

2019-02-19 15:52:49 147

原创 POJ1845-Sumdiv【算术基本定理 + 快速幂】

Consider two natural numbers A and B. Let S be the sum of all natural divisors of A^B. Determine S modulo 9901 (the rest of the division of S by 9901).InputThe only line contains the two natural n...

2019-02-18 12:13:48 194

原创 POJ1958-Strange Towers of Hanoi 【数论】

思路:经典汉诺塔有一个递推式a[i] = 2* a[i - 1] + 1,其中a[i]表示的是i个盘子要移动的次数,我们设f[n]表示4个塔时移动n个盘子的次数,可以得到递推式f[n] = min( 2 * f[i] + d[n - i]) , (1<= i < n), 表示的是先把i个盘子在4塔模式里移动到B柱,然后将剩下n-i个盘子在三塔模式下移动到D柱,最后把i个盘子在4塔模式下...

2019-02-17 21:05:42 222

原创 洛谷P1880 [NOI1995]石子合并【动态规划】

题目描述在一个圆形操场的四周摆放N堆石子,现要将石子有次序地合并成一堆.规定每次只能选相邻的2堆合并成新的一堆,并将新的一堆的石子数,记为该次合并的得分。试设计出1个算法,计算出将N堆石子合并成1堆的最小得分和最大得分.输入输出格式输入格式: 数据的第1行试正整数N,1≤N≤100,表示有N堆石子.第2行有N个数,分别表示每堆石子的个数. 输出格式: 输出共...

2019-02-17 17:01:24 293 2

原创 UVA136-Ugly Numbers 【优先队列】

Ugly numbers are numbers whose only prime factors are 2, 3 or 5. The sequence 1, 2, 3, 4, 5, 6, 8, 9, 10, 12, 15, ... shows the first 11 ugly numbers. By convention, 1 is included. Write a program to ...

2019-02-17 14:46:32 170

原创 UVA156-Ananagrams【字符串+STL】

题意:找出特定的单词,它们满足以下条件:这个单词经过重新排序后与其他单词不同,不分大小写,但输出时区分大小写。思路:就是先将单词转换为小写,将其排序,记录下来出现的次数就行了。#include<set>#include<map>#include<cstdio>#include<cmath>#include<queue>#in...

2019-02-17 11:49:43 161

原创 CSDN Markdown编辑器基础语法

@[TOC](这里写自定义目录标题)功能快捷键撤销:Ctrl/Command + Z重做:Ctrl/Command + Y加粗:Ctrl/Command + B斜体:Ctrl/Command + I标题:Ctrl/Command + Shift + H无序列表:Ctrl/Command + Shift + U有序列表:Ctrl/Command + Shift + O检查列表:...

2019-02-17 11:32:48 186

原创 UVA10815-Andy's First Dictionary 【set】

题意:就是给你许多行字符串,让你给每个单词按照字典序输出,不能有重复的,大写换成小写思路:这题用set来写非常方便,自带去重,而且string也非常方便,连接或者比较大小都很方便,这题需要注意的就是像aa'a'bb这是3个单词,需要分开,我第一法wa就是因为没有考虑这个问题。#include<set>#include<cstdio>#include<...

2019-02-14 21:43:16 322

原创 UVA10474-Where is the Marble?【二分查找】

题意:就是给你一组数,让你排序后能否找到某个数。思路:先排序一下,然后直接用二分查找就可以了,稍微注意一下输出,就是case的位置,亏我还跑了对数器,,,#include<cstdio>#include<cmath>#include<queue>#include<vector>#include<cstring>#inc...

2019-02-14 17:04:34 173

原创 CodeForces 1114C. Trailing Loves (or L'oeufs?)【数论】

Aki is fond of numbers, especially those with trailing zeros. For example, the number 92009200 has two trailing zeros. Aki thinks the more trailing zero digits a number has, the prettier it is.Howev...

2019-02-12 21:53:35 696

原创 POJ2418-Farey Sequence【欧拉函数】

The Farey Sequence Fn for any integer n with n >= 2 is the set of irreducible rational numbers a/b with 0 < a < b <= n and gcd(a,b) = 1 arranged in increasing order. The first few are F2 ...

2019-02-12 17:26:30 131

原创 POJ2115-C Looooops【扩展欧几里得】

A Compiler Mystery: We are given a C-language style for loop of type for (variable = A; variable != B; variable += C) statement;I.e., a loop which starts by setting variable to value A and wh...

2019-02-12 16:25:28 176 2

原创 POJ1061-青蛙的约会【扩展欧几里得】

两只青蛙在网上相识了,它们聊得很开心,于是觉得很有必要见一面。它们很高兴地发现它们住在同一条纬度线上,于是它们约定各自朝西跳,直到碰面为止。可是它们出发之前忘记了一件很重要的事情,既没有问清楚对方的特征,也没有约定见面的具体位置。不过青蛙们都是很乐观的,它们觉得只要一直朝着某个方向跳下去,总能碰到对方的。但是除非这两只青蛙在同一时间跳到同一点上,不然是永远都不可能碰面的。为了帮助这两只乐观的青蛙,...

2019-02-12 12:02:59 280

原创 HDU2161- Primes 【素数打表】

Write a program to read in a list of integers and determine whether or not each number is prime. A number, n, is prime if its only divisors are 1 and n. For this problem, the numbers 1 and 2 are not c...

2019-02-11 22:33:51 147

原创 UVA 11426-GCD - Extreme (II)【欧拉函数】

思路:这题比较不好想,我也是看了几位博主的题解才大概理解,参考链接。#include<cstdio>#include<cmath>#include<queue>#include<vector>#include<cstring>#include<iostream>#include<algorithm&

2019-02-11 19:03:32 203

原创 LightOJ 1220-Mysterious Bacteria【算书基本定理】

Dr. Mob has just discovered a Deathly Bacteria. He named it RC-01. RC-01 has a very strange reproduction system. RC-01 lives exactly x days. Now RC-01 produces exactly p new deadly Bacteria where x = ...

2019-02-10 20:41:53 160

原创 LightOJ 1138-Trailing Zeroes (III)【二分】

You task is to find minimal natural number N, so that N! contains exactly Q zeroes on the trail in decimal notation. As you know N! = 1*2*...*N. For example, 5! = 120, 120 contains one zero on the tra...

2019-02-10 19:45:07 208

原创 LightOJ 1197-Help Hanzo【素数筛】

Amakusa, the evil spiritual leader has captured the beautiful princess Nakururu. The reason behind this is he had a little problem with Hanzo Hattori, the best ninja and the love of Nakururu. After he...

2019-02-10 17:05:40 227

原创 LightOJ 1213-Fantasy of a Summation【快速幂】

If you think codes, eat codes then sometimes you may get stressed. In your dreams you may see huge codes, as I have seen once. Here is the code I saw in my dream.#include <stdio.h>int cases, c...

2019-02-10 17:01:05 227

原创 LightOJ 1214 Large Division 【大数取模】

Given two integers, a and b, you should check whether a is divisible by b or not. We know that an integer a is divisible by an integer b if and only if there exists an integer c such that a = b * c....

2019-02-10 11:07:17 176

原创 C++利用rand随机生成数据(序列,区间,树,图)

C++利用rand随机生成树随机生成整数随机生成区间随机生成树随机生成无向连通图

2019-02-09 13:04:46 3761

原创 LightOJ 1234-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...

2019-02-08 21:26:11 136

原创 LightOJ 1236-Pairs Forming LCM【算术基本定理】

Find the result of the following code:long long pairsFormLCM( int n ) {    long long res = 0;    for( int i = 1; i <= n; i++ )        for( int j = i; j <= n; j++ )           if( lcm(i, j) ...

2019-02-08 20:33:21 161

原创 LightOJ 1245-Harmonic Number (II)【数论、规律】

I was trying to solve problem '1234 - Harmonic Number', I wrote the following codelong long H( int n ) {    long long res = 0;    for( int i = 1; i <= n; i++ )        res = res + n / i;    ret...

2019-02-07 19:17:22 184

原创 LightOJ 1336-Sigma Function【数论思维】

Sigma function is an interesting function in Number Theory. It is denoted by the Greek letter Sigma (σ). This function actually denotes the sum of all divisors of a number. For example σ(24) = 1+2+3+4...

2019-02-07 16:19:36 157

原创 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]....

2019-02-07 15:37:10 207

原创 LightOJ 1282 Leading and Trailing 【快速幂+数学】

You are given two integers: n and k, your task is to find the most significant three digits, and least significant three digits of nk.InputInput starts with an integer T (≤ 1000), denoting the num...

2019-02-07 11:49:11 187

空空如也

空空如也

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

TA关注的人

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