自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

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

原创 Codeforces 1610C Keshi Is Throwing a Party

二分,贪心

2022-01-24 15:33:35 407

原创 Difference

题目链接题意定义 f(y,k)f(y,k)f(y,k) 为 yyy 各个数位上数字的 kkk 次方和,问有多少个不同的 yyy 满足 x=f(y,k)−yx=f(y,k)-yx=f(y,k)−y分析每个数位上的数字最大为9,假设 yyy 由 aaa 位9构成,那么 x=a∗9k−(10a−1)x=a*9^k - (10^a -1)x=a∗9k−(10a−1) ,kkk 最大为9,xxx...

2018-10-05 12:53:27 517

原创 2018 ICPC 徐州网络赛

A. Hard to prepare (dp)题意NNN个客人,主人手上有2k2k2^k个面具。 现在,NNN个人围着圆桌相邻而坐,主人会给他们每个人发一个面具,相邻两个人得到的面具i,ji,ji,j必须满足条件:iii XNORXNORXNOR jjj为正数。 问:有多少种方案?最终答案对 109+7109+710^9 + 7 取膜分析mask[i] XNOR mask[1...

2018-09-09 17:34:16 1068

原创 Print Article(HDU 3507 -- 斜率dp)

题目来源:http://acm.hdu.edu.cn/showproblem.php?pid=3507题意将nnn个数拆分成若干段,每段的打印代价为m+∑ki=1c[i]m+∑i=1kc[i]m+ \sum_{i=1}^k c[i],求最小代价分析dp[i]dp[i]dp[i] : 打印前 iii 页的最小代价 可以得到一个时间复杂度为O(n∗n)O(n∗n)O(n*n)...

2018-09-06 22:15:35 266

原创 Round Subset(codeforces 837D)

题目链接:[http://codeforces.com/problemset/problem/837/D]分析:末尾为零,显然是由2*5得到的。 对每一个aiaia_i进行分解,得到2和5的数量。大概计算一下,2的数量最多有12800个,5的数量最多有6000个,所以用5的数量作为背包容量,计算最多可以有多少个2。 转移方程为dp[i][k][j]=max{dp[i−1][k−1][j...

2018-08-23 15:51:45 348

原创 Change-free (codeforces 767E)

题目链接:[http://codeforces.com/contest/767/problem/E]分析:肯定要尽可能的不去换硬币,才能使代价最小。 如果至第i天,硬币数量不足以支付,那么应该在第1天至第i天中,选择代价最小的一天让收营员找零。可以发现不管是在哪一天获得硬币,硬币数量都是+100,但是每天的代价都不相同,代价的计算公式为:(100−ci%100)∗wi(100−ci%10...

2018-08-23 15:35:10 624

原创 Xor-sequences (codeforces 691E)

ProblemYou are given n integers a1,a2,...,ana1,  a2,  ...,  ana_1,  a_2,  ...,  a_n.A sequence of integers x1,x2,...,xkx1,  x2,  ...,  xkx_1,  x_2,  ...,  x_k is called a “xor-sequence” if for eve...

2018-08-23 15:20:54 480

原创 Rikka with Seam (DP+前缀和优化)

题目链接:[http://acm.hdu.edu.cn/showproblem.php?pid=6416]题目描述:给定一个N∗MN∗MN*M的01矩阵K-seam是满足以下条件的整数序列a:|a|=n,ai∈[1,m]|a|=n,ai∈[1,m] |a| = n , a_i \in [1,m]|ai−ai+1|≤K,i∈[1,n)|ai−ai+1|≤K,i∈[1,n) |...

2018-08-20 19:20:13 1126

原创 Shoot Game(区间dp)

题目链接:[http://acm.hdu.edu.cn/showproblem.php?pid=6365]DescriptionYou are playing a shooting game. The rules of the game are like this: You are in a two-dimensional plane and stand at (0,0). There...

2018-08-13 21:24:37 292

原创 Planning(贪心)

题目链接:[http://codeforces.com/problemset/problem/853/A]分析:记代价为totv,则totv=∑(b[i]−a[i])∗v[i]=∑b[i]∗v[i]−∑a[i]∗v[i]totv=∑(b[i]−a[i])∗v[i]=∑b[i]∗v[i]−∑a[i]∗v[i]totv = \sum (b[i]-a[i]) * v[i] = \sum b[i]...

2018-08-11 15:43:31 230

原创 Biridian Forest(BFS)

题目链接:[http://codeforces.com/problemset/problem/329/B]分析:其它的训练师都是坏人,想和你打架,如果你是他们,你会怎么做? 肯定是在必经之路等着,可是必经之路有很多,他们没有瞬移能力,但是有一个位置你必然要到达,就是出口,所以他们只要在出口等你就好了。 也就是说,只要能在你之前或与你同时到达的训练师,都会和你发生战斗。 以终点开始...

2018-08-11 15:36:10 360

原创 Food Delivery (区间dp)

DescriptionWhen we are focusing on solving problems, we usually prefer to stay in front of computers rather than go out for lunch. At this time, we may call for food delivery.Suppose there are N p...

2018-08-11 15:24:07 1231

原创 Cake(凸包+区间dp)

DescriptionYou want to hold a party. Here’s a polygon-shaped cake on the table. You’d like to cut the cake into several triangle-shaped parts for the invited comers. You have a knife to cut. The tra...

2018-08-11 14:35:02 361

原创 Coloring Brackets (区间dp)

DescriptionOnce Petya read a problem about a bracket sequence. He gave it much thought but didn’t find a solution. Today you will face it.You are given string s. It represents a correct bracket se...

2018-08-09 23:53:22 582

原创 You Are the One(区间dp)

DescriptionThe TV shows such as You Are the One has been very popular. In order to meet the need of boys who are still single, TJUT hold the show itself. The show is hold in the Small hall, so it at...

2018-08-08 10:04:24 289

原创 String painter(区间dp)

DescriptionThere are two strings A and B with equal length. Both strings are made up of lower case letters. Now you have a powerful string painter. With the help of the painter, you can change a seg...

2018-08-07 20:05:25 229

原创 Brackets(区间dp)

DescriptionWe give the following inductive definition of a “regular brackets” sequence:the empty sequence is a regular brackets sequence,if s is a regular brackets sequence, then (s) and [s] are...

2018-08-07 16:59:33 275

原创 Multiplication Puzzle (区间dp)

Multiplication Puzzle(区间dp)DescriptionThe multiplication puzzle is played with a row of cards, each containing a single positive integer. During the move player takes one card out of the row and...

2018-08-07 16:27:40 408

原创 Halloween Costumes(区间DP)

Halloween Costumes 区间DPDescriptionGappu has a very busy weekend ahead of him. Because, next weekend is Halloween, and he is planning to attend as many parties as he can. Since it’s Halloween, t...

2018-08-07 16:11:06 278 1

原创 HDU 3666 (差分约束)

Probelm You have been given a matrix C N*M, each element E of C N*M is positive and no more than 1000, The problem is that if there exist N numbers a1, a2, … an and M numbers b1, b2, …, bm, which ...

2018-07-31 09:45:41 328

原创 HDU1531(差分约束)

King Once, in one kingdom, there was a queen and that queen was expecting a baby. The queen prayed: “If my child was a son and if only he was a sound king.” After nine months her child was born, a...

2018-07-31 09:15:45 245

原创 HDU3592 World Exhibition

problem Nowadays, many people want to go to Shanghai to visit the World Exhibition. So there are always a lot of people who are standing along a straight line waiting for entering. Assume that the...

2018-07-30 10:40:46 281

原创 HDU 1384 Intervals(差分约束)

problem You are given n closed, integer intervals [ai, bi] and n integers c1, …, cn. Write a program that: reads the number of intervals, their endpoints and integers c1, …, cn from the st...

2018-07-30 10:14:38 242

原创 Codeforces 621E(dp+矩阵快速幂)

Wet Shark and Blocks题意 有 bbb 组数,每组都有相同的 nnn 个数,现要从每组数中选择一个数,联起来构成一个大数,使其对 xxx 取膜后的值为 kkk ,问有多少种方案?最终答案对 109+7109+710^9 + 7 取膜题解dp[j]dp[j] dp[j] : 对 xxx 取膜后的值为 jjj 的方案数 num[a]num[a]num[a] : 数字...

2018-07-24 19:13:31 267

原创 Codeforces 1005D(dp)

CF 1005D(dp)题意 给出一个长度不超过 2e52e52e5 的字符串 sss,将其分割成若干连续子段,不可有前导0,使得其构成的数中,为3的倍数的数量最多题解 dp[i]dp[i]dp[i] 记录至第 iii 位可以构成的3的倍数的数量 若 s[i]=0s[i]=0s[i]=0 , dp[i]=dp[i−1]+1dp[i]=dp[i−1]+1dp[i] = dp[i-1]+...

2018-07-22 23:41:22 269

原创 Codeforces Round#433 div 2

A.FractionPetya is a big fan of mathematics, especially its part related to fractions. Recently he learned that a fraction is called proper iff its numerator is smaller than its denominator (a < b) an

2017-10-15 20:10:27 263

原创 Codeforces Round #425 B

题目链接:http://codeforces.com/contest/832/problem/B题意: 首行给你一些小写字母,good character 第二行给你一段A字符串,含有小写字母 ? * ?只能匹配一个good character * 匹配空串和一段非good character 再给你n个字符串,问各个字符串是否能和A串匹配题解: 按照题意模拟就好,*可以匹配字符或字符

2017-08-25 20:39:27 382

原创 Good Sequences(codeforces 264B)

题目: Squirrel Liss is interested in sequences. She also has preferences of integers. She thinks n integers a1, a2, …, an are good.Now she is interested in good sequences. A sequence x1, x2, …, xk is ca

2017-08-21 10:46:17 651

原创 Array GCD

题目 You are given array ai of length n. You may consecutively apply two operations to this array:remove some subsegment (continuous subsequence) of length m < n and pay for it m·a coinschange some el

2017-08-18 19:55:48 433

原创 TrickGCD(莫比乌斯函数,容斥)

题目: You are given an array A , and Zhu wants to know there are how many different array B satisfy the following conditions? * 1≤Bi≤Ai * For each pair( l , r ) (1≤l≤r≤n) , gcd(bl,bl+1…br)≥2 Input

2017-08-18 16:51:14 422

原创 Matrix Power Series

题目: Given a n × n matrix A and a positive integer k, find the sum S = A + A^2 + A^3 + … + A^k.题解: 构造矩阵 A A 0 E 与单位矩阵进行k次矩阵乘法代码:#include <stdio.h>#include <stdlib.h>#include <string.h>#include

2017-08-18 15:08:40 298

原创 Blocks

题目: Panda has received an assignment of painting a line of blocks. Since Panda is such an intelligent boy, he starts to think of a math problem of painting. Suppose there are N blocks in a line and ea

2017-08-15 09:42:45 286

原创 M斐波那契数列

题目描述: M斐波那契数列F[n]是一种整数数列,它的定义如下: F[0] = a F[1] = b F[n] = F[n-1] * F[n-2] ( n > 1 ) 现在给出a, b, n,你能求出F[n]的值吗?( 0 <= a, b, n <= 10^9 ) 由于F[n]可能很大,你只需输出F[n]对1000000007取模后的值即可题解: 列出F[n]的前几项会发现,F

2017-08-15 09:27:58 476

原创 2017 summer individual contest(6)

A.Restaurant Tables(模拟)题意:a张单人桌,b张双人桌,有n组人来餐厅吃饭,每组只有一个或两个人。如果是一个人来,会给他安排单人桌,如果没有单人桌,则安排双人桌,如果仍然没有双人桌,则安排在已经有一位客人的双人桌,若仍然没有,只能拒绝提供服务。如果该组有两个人,则安排双人桌,若没有双人桌,则拒绝服务。按来的顺序给出每组人数(1 or 2),问需要拒绝为多少人服务?题解:注意决策

2017-08-08 21:01:24 220

原创 Shortest path of the king(贪心)

题目链接 : http://codeforces.com/problemset/problem/3/A题意:king有八个方向可以走,分别为L, R , U, D, LD, LU, RD ,RU 给出king的起点和终点, 问最少需要多少步数,并输出路径,路径可能不唯一。题解: 记起点和终点在横轴上的距离为tx,纵轴上的距离为ty;由tx,ty的正负值得到起点和终点的相对位置。若在横轴与

2017-06-21 12:31:04 327

原创 Codeforces 797E Array Queries

题目 describe a is an array of n positive integers, all of which are not greater than n. You have to process q queries to this array. Each query is represented by two numbers p and k. Several ope

2017-05-25 23:15:45 338

原创 2017 WUST校赛 1009 LL&a+b-c

LL is a ACMER. One day he find that the number 2 can be expressed as 1-2+3,which can also be expressed as 1+2+3-4 and so on. The number 5 can be expressed as 1-2-3+4+5, which can also be expresse

2017-05-23 20:41:15 278

原创 Codeforces 797B Odd sum

You are given sequence a1, a2, …, an of integer numbers of length n. Your task is to find such subsequence that its sum is odd and maximum among all such subsequences. It’s guaranteed that given sequen

2017-05-23 10:48:23 449

原创 BestCoder Round #84 Bellovin

Peter has a sequence a1,a2,…,ana1,a2,…,an and he define a function on the sequence – F(a1,a2,…,an)=(f1,f2,…,fn), where fi is the length of the longest increasing subsequence ending with ai. Peter w

2017-05-19 23:33:33 245

原创 Codeforces Round #408 /Mcvi Round #8 C Bank Hacking

题目大意: n家银行有n-1条网线相连,最初第i家银行的实力为a[i],且所有银行都在线。如果i和j有一条网线直接相连,则相邻;若i和k相邻,k和j相邻,则称i和j次相邻。当银行被攻击后,立即断线,与其相邻、次相邻的银行实力加1。现在Inzane开始他hack所有银行的计划,他选择hack的银行,需要满足3个条件:这家银行仍在线;它的相邻银行已经被hack;自己的实力需不低于银行实力。问:Inza

2017-05-19 23:09:59 281

空空如也

空空如也

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

TA关注的人

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