自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

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

原创 Counting Divisors HDU - 6069

In mathematics, the functiond(n)d(n)denotes the number of divisors of positive integernn.For example,d(12)=6d(12)=6because1,2,3,4,6,121,2,3,4,6,12are all1212's divisors.In this problem, gi...

2019-05-02 15:27:27 295 1

原创 三类博弈

巴什博奕:只有一堆n个物品,两个人轮流从这堆物品中取物,规定每次至少取一个,最多取m个。最后取光者得胜。保持给对手留下k(m+1),就可获胜。就是说谁面对k*(m+1)的情况谁输int m,n;scanf("%d%d",&n,&m);if(n%(m+1)==0) puts("No");else puts("YES");威佐夫博奕:有两堆各若干个物...

2019-04-08 17:32:27 357

原创 扩展欧几里得

看了这篇博客才稍微理解http://www.cnblogs.com/frog112111/archive/2012/08/19/2646012.html感恩。在此附上自己理解,加深记忆。扩展欧几里得基本算法:对于不完全为 0 的非负整数 a,b,必然存在整数对 x,y ,使得 gcd(a,b)=ax+by。(gcd即a,b的最大公约数)证明:1. b=0时,gcd(a...

2019-04-03 16:26:30 263

原创 数位dp例题(不要62)

杭州人称那些傻乎乎粘嗒嗒的人为62(音:laoer)。杭州交通管理局经常会扩充一些的士车牌照,新近出来一个好消息,以后上牌照,不再含有不吉利的数字了,这样一来,就可以消除个别的士司机和乘客的心理障碍,更安全地服务大众。不吉利的数字为所有含有4或62的号码。例如:62315 73418 88914都属于不吉利号码。但是,61152虽然含有6和2,但不是62连号,所以不属于不吉利数字之...

2019-04-01 21:33:48 335

原创 历届试题 k倍区间

问题描述  给定一个长度为N的数列,A1, A2, ... AN,如果其中一段连续的子序列Ai, Ai+1, ... Aj(i <= j)之和是K的倍数,我们就称这个区间[i, j]是K倍区间。  你能求出数列中总共有多少个K倍区间吗?输入格式  第一行包含两个整数N和K。(1 <= N, K <= 100000)  以下N行每行包含一个整数Ai。(1 <=...

2019-03-22 15:02:47 187

原创 历届试题 地宫取宝

问题描述  X 国王有一个地宫宝库。是 n x m 个格子的矩阵。每个格子放一件宝贝。每个宝贝贴着价值标签。  地宫的入口在左上角,出口在右下角。  小明被带到地宫的入口,国王要求他只能向右或向下行走。  走过某个格子时,如果那个格子中的宝贝价值比小明手中任意宝贝价值都大,小明就可以拿起它(当然,也可以不拿)。  当小明走到出口时,如果他手中的宝贝恰好是k件,则这些宝贝就可以送给小明。...

2019-03-20 14:33:37 207

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

2018-09-02 21:44:18 252

原创 51Nod - 1201 整数划分

将N分为若干个不同整数的和,有多少种不同的划分方式,例如:n = 6,{6} {1,5} {2,4} {1,2,3},共4种。由于数据较大,输出Mod 10^9 + 7的结果即可。Input输入1个数N(1 &lt;= N &lt;= 50000)。Output输出划分的数量Mod 10^9 + 7。Sample Input6Sample Output4题解...

2018-09-02 21:36:57 203

原创 HDU - 1251 统计难题

Ignatius最近遇到一个难题,老师交给他很多单词(只有小写字母组成,不会有重复的单词出现),现在老师要他统计出以某个字符串为前缀的单词数量(单词本身也是自己的前缀).Input输入数据的第一部分是一张单词表,每行一个单词,单词的长度不超过10,它们代表的是老师交给Ignatius统计的单词,一个空行代表单词表的结束.第二部分是一连串的提问,每行一个提问,每个提问都是一个字符串.注意:...

2018-09-02 20:58:12 186

原创 Farey Sequence

The Farey Sequence Fn for any integer n with n &gt;= 2 is the set of irreducible rational numbers a/b with 0 &lt; a &lt; b &lt;= n and gcd(a,b) = 1 arranged in increasing order. The first few areF2 =...

2018-08-27 21:42:22 331

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

2018-08-27 19:14:25 364

原创 HDU - 1087 Super Jumping! Jumping! Jumping!

Nowadays, a kind of chess game called “Super Jumping! Jumping! Jumping!” is very popular in HDU. Maybe you are a good boy, and know little about this game, so I introduce it to you now.The game c...

2018-08-26 21:21:08 215

原创 CodeForces - 645D Robot Rapping Results Report

While Farmer John rebuilds his farm in an unfamiliar portion of Bovinia, Bessie is out trying some alternative jobs. In her new gig as a reporter, Bessie needs to know about programming competition re...

2018-08-26 21:12:53 236

原创 HDU - 1226 超级密码

Ignatius花了一个星期的时间终于找到了传说中的宝藏,宝藏被放在一个房间里,房间的门用密码锁起来了,在门旁边的墙上有一些关于密码的提示信息:密码是一个C进制的数,并且只能由给定的M个数字构成,同时密码是一个给定十进制整数N(0&lt;=N&lt;=5000)的正整数倍(如果存在多个满足条件的数,那么最小的那个就是密码),如果这样的密码存在,那么当你输入它以后门将打开,如果不存在这样的密码.....

2018-08-26 20:49:40 238

原创 POJ - 2342 Anniversary party

There is going to be a party to celebrate the 80-th Anniversary of the Ural State University. The University has a hierarchical structure of employees. It means that the supervisor relation forms a tr...

2018-08-26 20:40:49 244

原创 UVA - 712 S-Trees

A Strange Tree (S-tree) over the variable set Xn = {x1,x2,...,xn} is a binary tree representing a Boolean function f : {0,1}n → {0,1}. Each path of the S-tree begins at the root node and consists of n...

2018-08-26 20:34:01 205

原创 HDU - 6375 度度熊学队列

度度熊正在学习双端队列,他对其翻转和合并产生了很大的兴趣。初始时有 NN 个空的双端队列(编号为 11 到 NN ),你要支持度度熊的 QQ 次操作。①11 uu ww valval 在编号为 uu 的队列里加入一个权值为 valval 的元素。(w=0w=0 表示加在最前面,w=1w=1 表示加在最后面)。②22 uu ww 询问编号为 uu 的队列里的某个元素并删除它。( w=0w=0 ...

2018-08-26 20:15:06 226

原创 UVA - 548 Tree

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...

2018-08-26 19:58:50 238

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

2018-08-26 19:46:53 289

原创 The Falling Leaves

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...

2018-08-22 18:50:11 247

原创 UVA - 839 Not so Mobile

Before being an ubiquous communications gadget, a mobile was just a structure made of strings and wires suspending colourfull things. This kind of mobile is usually found hanging over cradles of small...

2018-08-21 20:57:20 251

原创 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 with only one node; ...

2018-08-20 21:44:01 133

原创 CodeForces - 1006E Military Problem

In this problem you will have to help Berland army with organizing their command delivery system.There are n officers in Berland army. The first officer is the commander of the army, and he does not...

2018-08-19 21:28:30 252

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

2018-08-19 20:39:36 206

原创 CodeForces - 789C Functions again

Something happened in Uzhlyandia again... There are riots on the streets... Famous Uzhlyandian superheroes Shean the Sheep and Stas the Giraffe were called in order to save the situation. Upon the arr...

2018-08-19 20:31:21 339

原创 CodeForces - 505B Mr. Kitayuta's Colorful Graph

Mr. Kitayuta has just bought an undirected graph consisting of n vertices and m edges. The vertices of the graph are numbered from 1 to n. Each edge, namely edge i, has a color ci, connecting vertex a...

2018-08-18 20:44:42 238

原创 Binary Tree Traversals

In a postorder traversal of the vertices of T, we visit the vertices of T1 in postorder, then the vertices of T2 in postorder and finally we visit r.Now you are given the preorder sequence and inord...

2018-08-18 18:44:33 789

原创 Tree Recovery

Little Valentine liked playing with binary trees very much. Her favorite game was constructing randomly looking binary trees with capital letters in the nodes.This is an example of one of her creatio...

2018-08-18 16:22:22 247

原创 二叉搜索树

判断两序列是否为同一二叉搜索树序列Input开始一个数n,(1&lt;=n&lt;=20) 表示有n个需要判断,n= 0 的时候输入结束。接下去一行是一个序列,序列长度小于10,包含(0~9)的数字,没有重复数字,根据这个序列可以构造出一颗二叉搜索树。接下去的n行有n个序列,每个序列格式跟第一个序列一样,请判断这两个序列是否能组成同一颗二叉搜索树。Output如果序列相同则输出...

2018-08-18 12:31:16 350

原创 HDU - 1532 Drainage Ditches

Every time it rains on Farmer John's fields, a pond forms over Bessie's favorite clover patch. This means that the clover is covered by water for awhile and takes quite a long time to regrow. Thus, Fa...

2018-08-17 20:50:19 144

原创 CodeForces - 510C Fox And Names

Fox Ciel is going to publish a paper on FOCS (Foxes Operated Computer Systems, pronounce: "Fox"). She heard a rumor: the authors list on the paper is always sorted in the lexicographical order.After...

2018-08-17 18:52:38 241

原创 POJ - 3522 Slim Span

Given an undirected weighted graph G, you should find one of spanning trees specified as follows.The graph G is an ordered pair (V, E), where V is a set of vertices {v1, v2, …, vn} and E is a set of...

2018-08-16 20:01:41 284 1

原创 HDU - 1385 Minimum Transport Cost

These are N cities in Spring country. Between each pair of cities there may be one transportation track or none. Now there is some cargo that should be delivered from one city to another. The transpor...

2018-08-16 19:12:58 270

原创 HDU - 2120 Ice_cream's world I

ice_cream's world is a rich country, it has many fertile lands. Today, the queen of ice_cream wants award land to diligent ACMers. So there are some watchtowers are set up, and wall between watchtower...

2018-08-16 18:33:49 206

原创 51Nod - 1204 B - Parity

你的朋友写下一串包含1和0的串让你猜,你可以从中选择一个连续的子串(例如其中的第3到第5个数字)问他,该子串中包含了奇数个还是偶数个1,他会回答你的问题,然后你可以继续提问......你怀疑朋友的答案可能有错,或说同他之前的答案相互矛盾,例如:1 - 2 奇数,3 - 4 奇数,那么可以确定1 - 4 一定是偶数,如果你的朋友回答是奇数,就产生了矛盾。给出所有你朋友的答案,请你找出第一个出现矛盾的...

2018-08-16 18:13:43 165

原创 食物链 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句话,...

2018-08-14 20:04:50 149

原创 Subway POJ - 2502

You have just moved from a quiet Waterloo neighbourhood to a big, noisy city. Instead of getting to ride your bike to school every day, you now get to walk and take the subway. Because you don't want ...

2018-08-14 19:08:04 246

原创 Wormholes POJ - 3259

While exploring his many farms, Farmer John has discovered a number of amazing wormholes. A wormhole is very peculiar because it is a one-way path that delivers you to its destination at a time that i...

2018-08-14 19:00:23 272

原创 Play on Words POJ - 1386

Some of the secret doors contain a very interesting word puzzle. The team of archaeologists has to solve it to open that doors. Because there is no other way to open the doors, the puzzle is very impo...

2018-08-14 16:05:25 185

原创 确定比赛名次 HDU - 1285

有N个比赛队(1&lt;=N&lt;=500),编号依次为1,2,3,。。。。,N进行比赛,比赛结束后,裁判委员会要将所有参赛队伍从前往后依次排名,但现在裁判委员会不能直接获得每个队的比赛成绩,只知道每场比赛的结果,即P1赢P2,用P1,P2表示,排名时P1在P2之前。现在请你编程序确定排名。 Input输入有若干组,每组中的第一行为二个数N(1&lt;=N&lt;=500),M;其中N表...

2018-08-14 15:52:31 157

空空如也

空空如也

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

TA关注的人

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