自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

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

原创  LOOPS-HDU 3853 (DP&&期望)

题意:一个R*C的布局,每个格子中给出停留在原地,往右走一个,往下走一格的概率,起点在(1,1),终点在(R,C),每走一格消耗2的能量,求出最后所需要的能量期望。思路:dp[i][j]记录从i,j出发到终点的期望,p[i][j][k]记录每格三种状况的概率。1、dp[ i ][ j ] ---> dp[ i ][ j ],转移概率为p1;2、dp[ i ][ j ] ---> ...

2020-03-29 13:19:17 276

原创 Aeroplane chess(DP&&期望)

题意:走棋游戏,投掷1-6的骰子,投到x,就从这个格子向前走x步。到达的格子有飞机就继续向前飞,当到达>=n的格子,游戏结束,问到游戏结束时的数学期望。思路:从后往前推。dp[i]代表的是刀哥i格时还需要投的次数。dp[n]=0;从n-1开始,到达一个格子k分两种情况:1、有飞机dp[k]=dp[f[k]];2、没有飞机,就累加从这个格子之后的6个格子的期望*(1/6),然后还有加上...

2020-03-29 13:17:18 518

原创 Collecting Bugs (DP&&期望)

题意:一个软件有s个子系统,会产生n种bug,某个人一天发现一个bug,这个bug属于某种bug,发生在某个子系统里。求找到所有的n种bug和s个子系统所需的天数的数学期望。(程序中的bug数量几乎是无限的,因此在某个子系统中发现某个类别的新bug的概率在发现该子系统中的任何类别的bug之后不会减少,所以发现一个bug是某种bug的概率是1/n,属于某个子系统的概率是1/s)。思路:dp[i]...

2020-03-29 13:15:41 231

原创 Fibonacci again and again(SG函数)

任何一个大学生对菲波那契数列(Fibonacci numbers)应该都不会陌生,它是这样定义的:F(1)=1;F(2)=2;F(n)=F(n-1)+F(n-2)(n>=3);所以,1,2,3,5,8,13……就是菲波那契数列。在HDOJ上有不少相关的题目,比如1005 Fibonacci again就是曾经的浙江省赛题。今天,又一个关于Fibonacci的题目出现了...

2020-03-29 13:12:21 273

原创 H-取石子游戏(威佐夫博弈)

有两堆石子,数量任意,可以不同。游戏开始由两个人轮流取石子。游戏规定,每次有两种不同的取法,一是可以在任意的一堆中取走任意多的石子;二是可以在两堆中同时取走相同数量的石子。最后把石子全部取完者为胜者。现在给出初始的两堆石子的数目,如果轮到你先取,假设双方都采取最好的策略,问最后你是胜者还是败者。Input输入包含若干行,表示若干种石子的初始情况,其中每一行包含两个非负整数a和b,表示两堆石...

2020-03-29 13:08:46 218

原创 Too Many Segments (hard version)

题目链接:CodeForces - 1249D2 The only difference between easy and hard versions is constraints.You are givennnsegments on the coordinate axisOXOX. Segments can intersect, lie inside each other and ...

2019-11-01 14:59:49 424 1

原创 Too Many Segments (easy version)

题目链接:CodeForces - 1249D1The only difference between easy and hard versions is constraints.You are givennnsegments on the coordinate axisOXOX. Segments can intersect, lie inside each other and e...

2019-11-01 12:58:33 270

原创 By Elevator or Stairs?(从1楼到每层楼的最少时间)(动态规划)

题目链接:CodeForces - 1249E题目大意:你现在所处位置在1楼,给出你两组数据,第一组为从i到i+1走楼梯所需要的时间,第二组为从i到i+1坐电梯所需要的时间,从走楼梯转向电梯需要等c时间。从1楼向二楼走也需要等c时间。思路:动态规划。状态转移方程:dp[i][0]=min(dp[i-1][0]+b[i-1],dp[i-1][1]+b[i-1]+c);dp...

2019-10-31 21:59:32 340

原创 Good Numbers (hard version) (数据大)

Good NumbersThe only difference between easy and hard versions is the maximum value of n.You are given a positive integer number n. You really love good numbers so you want to find the smallest goo...

2019-10-31 21:36:41 380 1

原创 Good Numbers (easy version)

题目链接:CodeForces - 1249C1Good NumbersThe only difference between easy and hard versions is the maximum value of n.You are given a positive integer number n. You really love good numbers so you wa...

2019-10-31 21:30:59 690 1

原创 Books Exchange (hard version) (记忆化)

题目链接:CodeForces - 1249B2 The only difference between easy and hard versions is constraints.There arennkids, each of them is reading a unique book. At the end of any day, theii-th kid will give ...

2019-10-31 21:11:21 768 1

原创 KMP模板

一块花布条,里面有些图案,另有一块直接可用的小饰条,里面也有一些图案。对于给定的花布条和小饰条,计算一下能从花布条中尽可能剪出几块小饰条来呢?Input输入中含有一些数据,分别是成对出现的花布条和小饰条,其布条都是用可见ASCII字符表示的,可见的ASCII字符有多少个,布条的花纹也有多少种花样。花纹条和小饰条不会超过1000个字符长。如果遇见#字符,则不再进行工作。Output...

2019-10-19 17:49:54 589

原创 CodeForces - 1244D Paint the Tree

You are given a tree consisting ofnnvertices. A tree is an undirected connected acyclic graph. Example of a tre...

2019-10-19 11:11:35 240

原创 CodeForces - 1244E Minimizing Difference ()

You are given a sequencea1,a2,…,ana1,a2,…,anconsisting ofnnintegers.You may perform the following operation on this sequence: choose any element and either increase or decrease it by one.Calcu...

2019-10-19 10:56:48 216

原创 POJ-1182 食物链

动物王国中有三类动物A,B,C,这三类动物的食物链构成了有趣的环形。A吃B, B吃C,C吃A。现有N个动物,以1-N编号。每个动物都是A,B,C中的一种,但是我们并不知道它到底是哪一种。有人用两种说法对这N个动物所构成的食物链关系进行描述:第一种说法是"1 X Y",表示X和Y是同类。第二种说法是"2 X Y",表示X吃Y。此人对N个动物,用上述两种说法,一句接一句地说出K句话...

2019-08-17 11:30:51 214

原创 哈希

字符串哈希:https://blog.csdn.net/luyehao1/article/details/84930513

2019-08-16 20:14:12 137

原创 字符串

KMP详解:https://blog.csdn.net/v_july_v/article/details/7041827https://www.cnblogs.com/dusf/p/kmp.htmlhttps://www.cnblogs.com/ZuoAndFutureGirl/articles/9028287.htmlKMP模板:https://blog.csdn.net/D...

2019-08-15 20:47:53 154

原创 hdu 2674(N!Again)

WhereIsHeroFrom: Zty, what are you doing ?Zty: I want to calculate N!......WhereIsHeroFrom: So easy! How big N is ?Zty:...

2019-08-13 17:19:01 179

原创 Lightoj 1090 - Trailing Zeroes (II)

Find the number of trailing zeroes for the following function:nCr* pqwheren, r, p, qare given. For example, ifn = 10, r = 4, p = 1, q = 1, then the number is210so, number of trailing zeroes ...

2019-08-13 17:16:22 188

原创 HDU-4497 GCD and LCM

Given two positive integers G and L, could you tell me how many solutions of (x, y, z) there are, satisfying that gcd(x, y, z) = G and lcm(x, y, z) = L?Note, gcd(x, y, z) means the greatest common d...

2019-08-13 17:09:08 204

原创 数论知识

中国剩余定理:https://blog.csdn.net/qq_40772692/article/details/81872831扩展中国剩余定理:https://www.cnblogs.com/xiefengze1/p/10350652.html数论题目:https://blog.csdn.net/Soul_97/article/details/87904163...

2019-08-13 16:38:13 132

原创 POJ - 1061 青蛙的约会

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

2019-08-12 21:42:57 231

原创 UVA - 11426 GCD - Extreme (II)

思路:我们令f(n) = gcd(1, n) + gcd(2, n) + ... + gcd(n-1, n)则对应的结果s(n) = f(2) + f(3) + ... + f(n)所以s(n) = s(n-1)+f(n)因此我们只需求出所有的f(n),在递推即可取g(n, i)表示小于n且与n的gcd值等于i的数x的个数(gcd(n, x) = i)则f(n) = ...

2019-08-12 21:38:24 166

原创 LightOJ - 1138 Trailing Zeroes (III)

You task is to find minimal natural numberN, so thatN!contains exactlyQzeroes on the trail in decimal notation. As you knowN! = 1*2*...*N. For example, 5! = 120, 120 contains one zero on the tra...

2019-08-12 21:18:13 180

转载 线段树和扫描线

https://blog.csdn.net/xianpingping/article/details/83032798

2019-08-09 21:12:34 108

原创 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-08-09 19:15:05 240

原创 Harmonic Number (调和级数)

In mathematics, thenthharmonic number is the sum of the reciprocals of the firstnnatural numbers:In this problem, you are givenn, you have to findHn.InputInput starts with an integerT...

2019-08-09 18:03:34 586

原创 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-08-09 17:55:15 708

原创 LightOJ - 1282 Leading and Trailing(前三位和后三位)

You are given two integers:nandk, your task is to find the most significant three digits, and least significant three digits ofnk.InputInput starts with an integerT (≤ 1000), denoting the num...

2019-08-09 17:40:58 213

原创 LightOJ 1341 Aladdin and the Flying Carpet

It's said that Aladdin had to solve seven mysteries before getting the Magical Lamp which summons a powerful Genie. Here we are concerned about the first mystery.Aladdin was about to enter to a magi...

2019-08-09 17:29:18 184

原创 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 exactlyxdays. Now RC-01 produces exactlypnew deadly Bacteria wherex = b...

2019-08-09 17:19:37 216

原创 LightOJ 1370 Bi-shoe and Phi-shoe (欧拉函数)

Bamboo Pole-vault is a massively popular sport in Xzhiland. And Master Phi-shoe is a very popular coach for his success. He needs some bamboos for his students, so he asked his assistant Bi-Shoe to go...

2019-08-09 17:06:28 165

原创 UVA - 112 Tree Summing (难在输入)

LISP was one of the earliest high-level programming languages and, with FORTRAN, is one of the oldest languages currently being used. Lists, which are the fundamental data structures in LISP, can ea...

2019-08-08 21:06:16 229

原创 HDU - 5444 Elven Postman (根节点到指定节点的路径)

Elves are very peculiar creatures. As we all know, they can live for a very long time and their magical prowess are not something to be taken lightly. Also, they live on trees. However, there is somet...

2019-08-08 20:59:22 271

原创 HDU - 1622 Trees on the level (二叉树的水平遍历)

Trees are fundamental in many branches of computer science. Current state-of-the art parallel computers such as Thinking Machines' CM-5 are based on fat trees. Quad- and octal-trees are fundamental to...

2019-08-08 20:51:31 267

原创 UVA - 297 Quadtrees(四分图)

A quadtree is a representation format used to encode images. The fundamental idea behind the quadtree is that any image can be split into four quadrants. Each quadrant may again be split in four sub q...

2019-08-08 20:35:56 248

原创 UVA - 699 The Falling Leaves (二叉搜索和STL)

Each year, fall in the North Central region is accompanied by the brilliant colors of the leaves on the trees, followed quickly by the falling leaves accumulating under the trees. If the same thing ha...

2019-08-08 20:20:24 195

原创 Tree UVA - 548 (中序和后序,求根节点到叶节点的和最小)

You are to determine the value of the leaf node in a given binary tree that is the terminal node of a path of least value from the root of the binary tree to any leaf. The value of a path is the sum o...

2019-08-08 20:06:47 224

原创 HDU-3999 The order of a Tree (前序遍历)

As we know,the shape of a binary search tree is greatly related to the order of keys we insert. To be precisely:1.insert a key k to a empty tree, then the tree become a tree withonly one node;...

2019-08-06 16:56:14 167

原创 HDU-1710 Binary Tree Traversals (知前中推后)

A binary tree is a finite set of vertices that is either empty or consists of a root r and two disjoint binary trees called the left and right subtrees. There are three most important ways in which th...

2019-08-06 16:48:16 180

空空如也

空空如也

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

TA关注的人

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