自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

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

原创 D - Alternative Thinking

Kevin has just recevied his disappointing results on the USA Identification of Cows Olympiad (USAICO) in the form of a binary string of length n. Each character of Kevin's string represents Kevin's sco

2017-08-24 10:53:53 392

原创 C - Almost Prime

A number is called almost prime if it has exactly two distinct prime divisors. For example, numbers 6, 18, 24 are almost prime, while 4, 8, 9, 42 are not. Find the amount of almost prime numbers which

2017-08-22 16:57:53 406

原创 周赛4-Levko and Permutation

Levko loves permutations very much. A permutation of length n is a sequence of distinct positive integers, each is at most n.Let’s assume that value gcd(a, b) shows the greatest common divisor of numbe

2017-08-22 16:22:37 241

原创 P - 青蛙的约会

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

2017-08-18 16:22:18 208

原创 H - Primes or Palindromes?

Rikhail Mubinchik believes that the current definition of prime numbers is obsolete as they are too complex and unpredictable. A palindromic number is another matter. It is aesthetically pleasing, and

2017-08-17 21:03:31 217

原创 B - Soldier and Number Game

Two soldiers are playing a game. At the beginning first of them chooses a positive integer n and gives it to the second soldier. Then the second one tries to make maximum possible number of rounds. Eac

2017-08-17 19:06:30 440

原创 L - The Euler function (欧拉筛)

The Euler function phi is an important kind of function in number theory, (n) represents the amount of the numbers which are smaller than n and coprime to n, and this function has a lot of beautiful ch

2017-08-17 15:17:14 342

原创 I - Modified GCD (最大公约数,打表)

Well, here is another math class task. In mathematics, GCD is the greatest common divisor, and it's an easy task to calculate the GCD between two positive integers.A common divisor for two positive num

2017-08-16 20:08:41 449

原创 D - Dima and Lisa

Dima loves representing an odd number as the sum of multiple primes, and Lisa loves it when there are at most three primes. Help them to represent the given number as the sum of at most than three prim

2017-08-16 15:35:13 290

原创 F - Plant (快速幂)

Dwarfs have planted a very interesting plant, which is a triangle directed "upwards". This plant has an amusing feature. After one year a triangle plant directed "upwards" divides into four triangle pl

2017-08-16 15:30:33 251

原创 A - Drazil and His Happy Friends

Drazil has many friends. Some of them are happy and some of them are unhappy. Drazil wants to make all his friends become happy. So he invented the following plan.There are n boys and m girls among his

2017-08-16 10:04:43 254

原创 E - M斐波那契数列 (费马小定理 + 二分快速幂 + 矩阵快速幂)

题解F(0)=a,F(1)=b F(n)=F(n−1)F(n−2) ⇒F(n)=F(n−2)2F(n−3) ⇒F(n)=F(n−3)3F(n−4)2 ⇒F(n)=F(n−4)5F(n−5)3 … ⇒F(n)=F(1)f(n)F(0)f(n−1) ⇒F(n)=bf(n)af(n−1) f(n)正是斐波那契数列。 矩阵快速幂可以求出f(n),f(n−1)的值。 然后快速幂计算bf(n

2017-08-15 16:48:15 258

原创 B - Matrix Power Series

Given a n × n matrix A and a positive integer k, find the sum S = A + A2 + A3 + … + Ak.InputThe input contains exactly one test case. The first line of input contains three positive integers n (n ≤ 30

2017-08-15 15:48:29 200

原创 G - Porcelain(预处理加背包)

During her tantrums the princess usually smashes some collectable porcelain. Every furious shriek is accompanied with one item smashed.The collection of porcelain is arranged neatly on n shelves. Withi

2017-08-15 09:24:54 230

原创 D - Rent your airplane and make money SPOJ - RENT

"ABEAS Corp." is a very small company that owns a single airplane. The customers of ABEAS Corp are large airline companies which rent the airplane to accommodate occasional overcapacity.Customers send

2017-08-14 10:38:37 400

原创 B - 2048

2048 is a single-player puzzle game created by Gabriele Cirulli1. It is played on a 4×4 grid that contains integers ≥2that are powers of 2. The player can use a keyboard arrow key (left/up/right/down)

2017-08-13 23:36:52 667

原创 C - ABC

You will be given three integers A, B and C. The numbers will not be given in that exact order, but we do know that A is less than B and B less than C. In order to make for a more pleasant viewing, we

2017-08-12 23:40:28 585

原创 A - 3D Printed Statues(周赛3)

You have a single 3D printer, and would like to use it to produce nstatues. However, printing the statues one by one on the 3D printer takes a long time, so it may be more time-efficient to first use t

2017-08-12 23:31:50 255

原创 A - Fibonacci

In the Fibonacci integer sequence, F0 = 0, F1 = 1, and Fn = Fn − 1 + Fn − 2 for n ≥ 2. For example, the first ten terms of the Fibonacci sequence are:0, 1, 1, 2, 3, 5, 8, 13, 21, 34, …An alternative fo

2017-08-11 15:47:17 657

原创 整数快速乘法/快速幂+矩阵快速幂

快速乘法通常有两类应用:一、整数的运算,计算(a*b) mod c 二、矩阵快速乘法 一、整数运算:(快速乘法、快速幂)先说明一下基本的数学常识:(a*b) mod c == ( (a mod c) * (b mod c) ) mod c //这最后一个mod c 是为了保证结果不超过c对于2进制,2n可用1后接n个0来表示、对于8进制,可用公式 i+3*j == n (其中 0<= i <=2

2017-08-11 14:57:25 640

原创 H - 3的幂的和(快速幂)

求:3^0 + 3^1 +...+ 3^(N) mod 1000000007Input 输入一个数N(0 <= N <= 10^9) Output 输出:计算结果 Sample Input3Sample Output40要用到的知识:**逆元: 若对于数字A,C 存在X,使A * X = 1 (mod C) ,那么称X为 A 对C的乘法逆元。 理论依据: F /

2017-08-11 10:19:12 474

原创 H - 数塔

在讲述DP算法的时候,一个经典的例子就是数塔问题,它是这样描述的:有如下所示的数塔,要求从顶层走到底层,若每一步只能走到相邻的结点,则经过的结点的数字之和最大是多少?已经告诉你了,这是个DP的题目,你能AC吗? Input 输入数据首先包括一个整数C,表示测试实例的个数,每个测试实例的第一行是一个整数N(1 <= N <= 100),表示数塔的高度,接下来用N行数字表示数塔,其中第i行有

2017-08-10 21:06:00 164

原创 G - 子序列个数

子序列的定义:对于一个序列a=a1,a2,......an。则非空序列a'=ap1,ap2......apm为a的一个子序列,其中1<=p1<p2<.....<pm<=n。 例如4,14,2,3和14,1,2,3都为4,13,14,1,2,3的子序列。对于给出序列a,有些子序列可能是相同的,这里只算做1个,请输出a的不同子序列的数量。由于答案比较大,输出Mod 10^9 + 7的结果即可

2017-08-10 19:40:31 155

原创 动态规划经典问题

子串:在给定的字符串中选取连续的一段 子序列:可以不连续,但是要保证出现的顺序与原字符串相同 比如字符串ABCDEFG ABC既是子串又是子序列 ACD只是子序列一、最大连续子序列和 给定一个整数序列A1,A2……An。求最大的连续的子序列的和。 比如{1,-2,3,1,-1,2}的最大连续子序列的和为5(3+1-1+2)万能枚举???每次枚举l和r,求区间[l,r]的和 时间复杂度O

2017-08-10 15:21:53 175

原创 F - 最长递增子序列

给出长度为N的数组,找出这个数组的最长递增子序列。(递增子序列是指,子序列的元素是递增的)例如:5 1 6 8 2 4 5 10,最长递增子序列是1 2 4 5 10。Input 第1行:1个数N,N为序列的长度(2 <= N <= 50000) 第2 - N + 1行:每行1个数,对应序列的元素(-10^9 <= Si <= 10^9) Output

2017-08-10 14:50:26 228 1

原创 A - 最大子段和 B - 循环数组最大子段和

一: A - 最大子段和 N个整数组成的序列a1,a2,a3,…,an, 求该序列如ai+ai+1+…+aj 的连续子段和的最大值。当所给的整数均为负数时和为0。 例如:-2,11,-4,13,-5,-2,和最大的子段为:11,-4,13。和为20。 Input 第1行:整数序列的长度N(2 <= N <= 50000) 第2 - N + 1行:N个整数

2017-08-09 23:46:42 438

原创 C - Common Subsequence E - 编辑距离 D - 最长公共子序列Lcs(dp经典!!)

一!!! 编辑距离,又称Levenshtein距离(也叫做Edit Distance),是指两个字串之间,由一个转成另一个所需的最少编辑操作次数。许可的编辑操作包括将一个字符替换成另一个字符,插入一个字符,删除一个字符。 例如将kitten一字转成sitting: sitten (k->s) sittin (e->i) sitting (->g)

2017-08-09 20:03:26 525

转载 01背包问题和完全背包问题 (转载)

*原链接: http://blog.csdn.net/kangroger/article/details/38864689*01背包问题:一个背包总容量为V,现在有N个物品,第i个 物品体积为weight[i],价值为value[i],现在往背包里面装东西,怎么装能使背包的内物品价值最大?看到这个问题,可能会想到贪心算法,但是贪心其实是不对的。例如最少硬币找零问题,要用动态规划。动态规划思想就是解

2017-08-08 09:57:34 467

转载 (2017.8.5周赛2) A - Dropping tests POJ - 2976(01数分规划)

【关键字】0/1分数规划、最优比率生成树、最优比率环

2017-08-07 09:10:42 182

空空如也

空空如也

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

TA关注的人

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