自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

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

原创 BestCoder Round #74

A题 链接:http://acm.hdu.edu.cn/showproblem.php?pid=5635官方题解:如果a_i=xa​i​​=x, 那么可以推断出s_i=s_{i+1}=...=s_{i+x}s​i​​=s​i+1​​=...=s​i+x​​, 并且如果a_i \ne 0a​i​​≠0, 那么a_{i+1}=a_i-1a​i+1​​=a​i​​−1, 利用第二

2016-03-31 22:59:31 234

原创 BestCoder Round #75

A题 链接:http://acm.hdu.edu.cn/showproblem.php?pid=5640官方题解:显然这很像求最大公约数的过程嘛,看这张神图:所以每次 \gcdgcd 的时候累加答案即可,复杂度 O(\log\max(n, m)T)O(logmax(n,m)T)。当然你要是循环减应该也放过了。我的思考:就是一直长的减短的,减到不能再减为止#inc

2016-03-30 23:45:45 255

原创 BestCoder Round #76

A题 链接http://acm.hdu.edu.cn/showproblem.php?pid=5645官方题解:因为数据规模很小,所以直接用O(n^2)O(n​2​​)时间求出有多少对(i,j)(i,j)满足a_ia​i​​a​j​​,然后再除以n(n-1)/2n(n−1)/2即可。当然也有O(n\log n)O(nlogn)的做法,也很简单。时间复杂度O(n^2)O(

2016-03-30 12:54:16 336

原创 BestCoder Round #77

A题 链接http://acm.hdu.edu.cn/showproblem.php?pid=5650官方题解:我们考虑集合中的每个数x对答案的贡献。 设集合有n个数,则包含x的子集个数有2^(n-1)个。 那么当n > 1时,x出现了偶数次,所以其对答案的贡献就是0;当 n = 1时,其对答案的贡献是 x。我的思考:当时想的时候题目看错以为是集合中所有元素相加之后再异或,导致用了队列,d

2016-03-29 00:02:52 389

原创 hdu 4571 Travel in time(floyd+dp)

链接http://acm.hdu.edu.cn/showproblem.php?pid=4571距离上的cost用floyd算是否停留用dp求最后遍历dp[i][j]搜索答案#include#include#includeusing namespace std;typedef struct{ int c,s,num;}Point;int g[105][105]

2016-03-21 23:35:43 370

原创 校第十六届大学生程序设计竞赛暨2016省赛集训队选拔赛1007

Problem GProblem DescriptionGomoku is an abstract strategy board game. Named Gobang or Five in a Row as well, it is traditionally played with pieces of two colors (black and white) on a board

2016-03-21 21:48:46 736

原创 校第十六届大学生程序设计竞赛暨2016省赛集训队选拔赛1002

Problem BTime Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 254    Accepted Submission(s): 11Problem DescriptionAs you know, mazes

2016-03-20 21:17:21 770

原创 hdu 3182 Hamburger Magi(状压dp)

链接:http://acm.hdu.edu.cn/showproblem.php?pid=3182预处理+dp#include#include#includeusing namespace std;const int N=15;int val[N],cost[1<<N],energy[N],last[N];int dp[1<<N];int n,m;void init(){

2016-03-19 14:51:50 439

原创 hdu 1503 Advanced Fruits(最长公共子序列+路径记录)

链接:http://acm.hdu.edu.cn/showproblem.php?pid=1503最长公共子序列+路径记录#include#includeusing namespace std;const int N=105;int dp[N][N],pre[N][N];char s1[N],s2[N];void out(int i,int j){ if(i==0&&

2016-03-17 21:09:51 366

原创 hdu 1729 Stone Game(SG函数)

Stone GameProblem DescriptionThis game is a two-player game and is played as follows:1. There are n boxes; each box has its size. The box can hold up to s stones if the size is s.2. At t

2016-03-13 11:37:11 393

原创 hdu 1556 Color the ball(树状数组)

Color the ballProblem DescriptionN个气球排成一排,从左到右依次编号为1,2,3....N.每次给定2个整数a b(a  Input每个测试实例第一行为一个整数N,(N  Output每个测试实例输出一行,包括N个整数,第I个数代表第I个气球总共被涂色的次数。 Sample Input31 12 23

2016-03-12 14:05:27 349

原创 hdu 1829 A Bug's Life(种类并查集)

A Bug's LifeProblem DescriptionBackground Professor Hopper is researching the sexual behavior of a rare species of bugs. He assumes that they feature two different genders and that they only

2016-03-08 22:14:38 463

原创 hdu 4496 D-City(并查集逆向思维)

D-CityProblem DescriptionLuxer is a really bad guy. He destroys everything he met. One day Luxer went to D-city. D-city has N D-points and M D-lines. Each D-line connects exactly two D-points.

2016-03-08 21:51:41 321

原创 中国剩余定理的应用及证明

中国剩余定理在ACM中主要用来解方程中国剩余定理需要用到扩展欧几里得算法就从欧几里得算法开始讲起LL gcd(LL a,LL b){    Return b==0?a:gcd(b,a%b);}     b==0时我们返回a作为最大公约数,现在就是判断a和b的最大公约数是不是等于b和a%b的最大公约数设a除b=k……r第一步:令c=gcd(a,b) 则设a=mc 

2016-03-08 00:18:58 1885

原创 hdu 1598 find the most comfortable road(并查集判断图联通)

find the most comfortable roadTime Limit: 1000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 5719    Accepted Submission(s): 2477Problem Description

2016-03-07 21:24:39 312

原创 hdu 1198 Farm Irrigation(并查集强大无比的位运算)

Farm IrrigationTime Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 8223    Accepted Submission(s): 3543Problem DescriptionBenny has a sp

2016-03-07 19:50:05 368

原创 hdu 3038 How Many Answers Are Wrong(并查集变种)

How Many Answers Are WrongTime Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 4639    Accepted Submission(s): 1770Problem DescriptionTT

2016-03-07 19:19:48 288

原创 hdu 4081 Qin Shi Huang's National Road System(最小生成树变形)

Qin Shi Huang's National Road SystemProblem DescriptionDuring the Warring States Period of ancient China(476 BC to 221 BC), there were seven kingdoms in China ---- they were Qi, Chu, Y

2016-03-03 18:26:32 269

原创 hdu 检测赛 Problem C(状压dp)

Problem CProblem Description新年伊始,集训队迎来了15级新生。教练打算将大家N(2Input多组用例,处理到EOF对于每组用例:第一行 N接下来的N行,每行N个数第i行第j个数表示i和j分到两个队时彼此的思念值第i行第j个数等于第j行第i个数,当i=j时,思念值为0Output思念值总值的最大值Sample Input

2016-03-03 11:52:41 303

原创 hdu 检测赛(最短路中途必须经过两个点)

Problem G没做过这样的题目完全没思路Problem Description给定n个点,m条无向边,1为起点,求从起点出发,至少经过两个点(非起点)并且回到最终回到起点的最短路(中途可以经过起点)点的编号为1到nInput多组用例每个用例的第一行是2个整数n和m(2接下来的m行里,每行包括3个整数a,b,c.代表a和b之间有一条通路,长度为c(0O

2016-03-03 10:32:42 1936 1

原创 hdu 4436 str2int(后缀数组)

str2intProblem DescriptionIn this problem, you are given several strings that contain only digits from '0' to '9', inclusive.An example is shown below.101123The set S of strings is con

2016-03-01 09:20:50 576

空空如也

空空如也

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

TA关注的人

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