自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

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

原创 bfs寻找最短路径并且打印路径和方向

import java.util.*;public class Main { static Scanner in = new Scanner(System.in); static int m,n,sp,ep; static int[][] vis = new int[105][105]; static int[][] ma = new int[105][105];

2017-10-30 20:39:07 2797

原创 搜索算法king——A*初识

最近在做搜索的练习,老是听到大神们说什么A*算法,听起很高大上的样子,于是我这个菜鸟出于好奇百度了一下,发现真是好玩死了,对于搜索算法我们都知道有深搜和广搜,深搜一般用来解决数据不是很大(二维数组一般不超过20),并且有的时候需要搜索全部可能性的时候,而广搜除了可以用来解决上述问题以外,还可以用来解决最优解问题。但是大家都清楚,深搜对于时间复杂度有要求而广搜对于空间的消耗也是很大,那么A*算法便脱

2017-10-29 13:50:29 519

原创 E - Digital Square --模拟暴力dfs

Given an integer N,you should come up with the minimum nonnegative integer M.M meets the follow condition: M 2%10 x=N (x=0,1,2,3....)InputThe first line has an integer T( TFor each case, each li

2017-10-29 11:46:37 332

原创 fire!--两次bfs

Fire!Joe works in a maze. Unfortunately,portions of the maze have caught on fire, and the owner of the maze neglectedto create a fire escape plan. Help Joe escape the maze.Given Joe's location in the ...

2017-10-28 16:33:17 588

原创 Find a way -从两个点分别bfs

Pass a year learning in Hangzhou, yifenfei arrival hometown Ningbo at finally. Leave Ningbo one year, yifenfei have many people to meet. Especially a good friend Merceki. Yifenfei’s home is at the c

2017-10-28 12:51:16 350

原创 Oil Deposits --dfs

The GeoSurvComp geologic survey company is responsible for detecting underground oil deposits. GeoSurvComp works with one large rectangular region of land at a time, and creates a grid that divides th

2017-10-28 10:41:29 268

原创 A-素数环dfs

A ring is compose of n circles as shown in diagram. Put natural number 1, 2, ..., n into each circle separately, and the sum of numbers in two adjacent circles should be a prime. Note: the number

2017-10-28 09:13:17 345

原创 放苹果 --动态规划、递归

把M个同样的苹果放在N个同样的盘子里,允许有的盘子空着不放,问共有多少种不同的分法?(用K表示)5,1,1和1,5,1 是同一种分法。Input第一行是测试数据的数目t(0 Output对输入的每组数据M和N,用一行输出相应的K。Sample Input17 3Sample Output8分析:设f(m,n)为m个苹果,n个盘子的

2017-10-21 22:36:44 454

原创 前进杀蝙蝠--简单递归

轻松通过墓碑,进入古墓后,才发现里面别有洞天。 突然,Yifenfei发现自己周围是黑压压的一群蝙蝠,个个扇动翅膀正准备一起向他发起进攻! 形势十分危急! 好在此时的yifenfei已经不是以前那个经常被lemon抢走MM的菜鸟了!面对众多蝙蝠的嗜血狂攻,只见yifenfei使出轻灵的剑法,刷,刷,刷,瞬间搞定…… 现已知yifenfei使用了2招(剑招A和剑招B):剑招A,一招能

2017-10-21 20:13:11 550

原创 蟠桃记 --简单递归

喜欢西游记的同学肯定都知道悟空偷吃蟠桃的故事,你们一定都觉得这猴子太闹腾了,其实你们是有所不知:悟空是在研究一个数学问题! 什么问题?他研究的问题是蟠桃一共有多少个! 不过,到最后,他还是没能解决这个难题,呵呵^-^ 当时的情况是这样的: 第一天悟空吃掉桃子总数一半多一个,第二天又将剩下的桃子吃掉一半多一个,以后每天吃掉前一天剩下的一半多一个,到第n天准备吃的时候只剩下一个桃子。聪

2017-10-21 19:03:05 1080

原创 小明的花店---简单DP

题目描述 小明的花店新开张,为了吸引顾客,他想在花店的门口摆上一排花,共m盆。通过调查顾客的喜好,小明列出了顾客最喜欢的n种花,从1到n标号。为了在门口展出更多种花,规定第i种花不能超过ai盆,摆花时同一种花放在一起,且不同种类的花需按标号从小到大的顺序依次摆列。    试编程计算,一共有多少种不同的摆花方案。输入 第一行包含两个正整数n和m,中间用一个空格隔开

2017-10-21 13:28:37 2433

原创 超级楼梯 --斐波那契数列

有一楼梯共M级,刚开始时你在第一级,若每次只能跨上一级或二级,要走上第M级,共有多少种走法?Input输入数据首先包含一个整数N,表示测试实例的个数,然后是N行数据,每行包含一个整数M(1Output对于每个测试实例,请输出不同走法的数量Sample Input223Sample Output12import java.util.*;public class

2017-10-17 09:21:52 656

原创 红黑瓷砖--dfs求解

有一个矩形房间,覆盖正方形瓷砖。每块瓷砖涂成了红色或者黑色。一名男子站在黑色的瓷砖上,由此出发,可以移到四个相邻瓷砖之一。但是他不能移到红砖上,只能移动到黑砖上。编写一个程序,计算通过重复上述移动所能经过的黑砖数。输入输入包含多个数据集,一个数据集开头行包含两个正整数W和H,W和H分别表示矩形房间的列数和行数,且都不超过20。 每个数据集有H行,其中每行包括W个字符。每个字符的含义如下:‘.’ –...

2017-10-16 14:03:17 1787

原创 jump--不跳脏楼梯

题目描述小男孩Petya非常喜欢楼梯。但是他从简单的上下去无聊,他一次又喜欢跳上几层楼梯。当他站在一些楼梯上时,他可以跳到下一个楼梯,或者一次跳过一两个楼梯。但是一些楼梯太脏了,Petya不想踩踏他们。现在Petya在楼梯的第一层,由n个楼梯组成。他也知道这个楼梯的肮脏楼梯的数量。帮助Petya找出他是否可以跳过整个楼梯,到达最后的楼梯号码n,而不用肮脏的楼梯一次。输入

2017-10-16 08:57:33 318

原创 数字序列

题目描述数字序列定义如下:f(1)= 1,f(2)= 1,f(n)=(A * f(n-1)+ B * f(n-2))% 7。给定A,B和n,你要计算f(n)的值。输入输入由多个测试用例组成。 每个测试用例在单行(1 三个零信号表示输入的结束,此测试用例不被处理。输出对于每个测试用例,在单行上打印f(n)的值。样例输入1 1

2017-10-16 08:50:52 525

原创 Ekka Dokka -- 乘积奇数最大偶数最小

Ekka and his friend Dokka decided to buy a cake. They both love cakes and that's why they want to share the cake after buying it. As the name suggested that Ekka is very fond of odd numbers and Dokka

2017-10-07 15:31:11 529

原创 Good Numbers

if we sum up every digit of a number and the result can be exactly divided by 10, we say this number is a good number.You are required to count the number of good numbers in the range from A to B,

2017-10-06 23:38:10 628

原创 犯罪嫌疑人--逻辑推理

福尔摩斯是个大侦探,他总是在解决疑难案件。这一次的案件也不例外,案件是这样的:有编号为1到N的N位嫌疑犯,他们其中有一个犯了罪,然后每个嫌疑犯都被询问,“哪一个人犯了罪?”犯罪嫌疑人的答案只能“编号ai的嫌疑犯犯了罪”或者“编号ai的嫌疑犯没有犯罪”。当然嫌疑犯也可以说他自己(ai = i).福尔摩斯凭着他敏锐的侦探直觉,确定地对华生说,只有M个人说了真话,其余人都是说谎。然后就没有然后了,但

2017-10-06 22:28:23 1478

原创 Colored Sticks --欧拉回路,并查集,字典树,

You are given a bunch of wooden sticks. Each endpoint of each stick is colored with some color. Is it possible to align the sticks in a straight line such that the colors of the endpoints that touch a...

2017-10-06 17:37:56 452

原创 February 29 --容斥原理

It is 2012, and it's a leap year. So there is a "February 29" in this year, which is called leap day. Interesting thing is the infant who will born in this February 29, will get his/her birthday again

2017-10-06 12:20:20 424

原创 Discover the Web

Standard web browsers contain features to move backward and forward among the pages recently visited. One way to implement these features is to use two stacks to keep track of the pages that can be re

2017-10-05 22:44:34 396

原创 位运算

位运算在很多时候可以提高效率,小小的一行也能成为程序的亮点,今天简单介绍一下位运算以及一些小技巧,希望以后我可以想着用一下一、逻辑运算1.逻辑&,就是将两个数的二进制按位进行&(同1则1),如果有负数,则按照补码进行运算应用:(1) 清零 清零:将其全部的二进制位全部置为0。例如整型数a=321对其全部数据清零的操作为a=a&0x00。 321=0000 0001 0100

2017-10-05 17:20:30 323

转载 Secret Origins

This is the tale of Zephyr, the greatest time traveler the world will never know. Even those who are aware of Zephyr's existence know very little about her. For example, no one has any clue as to whic

2017-10-05 16:35:11 327

原创 字典树--java 定义

public class Trie{ private int SIZE=26; private TrieNode root;//字典树的根 Trie() //初始化字典树 { root=new TrieNode(); } private class TrieNode //字典树节点 { private

2017-10-05 13:47:46 790

原创 DNA Prefix--字典树

Given a set of n DNA samples, where each sample is a string containing characters from {A, C, G, T}, we are trying to find a subset of samples in the set, where the length of the longest common prefix

2017-10-05 13:17:31 528

原创 Fibsieve`s Fantabulous Birthday

Fibsieve had a fantabulous (yes, it's an actual word) birthday party this year. He had so many gifts that he was actually thinking of not having a party next year.Among these gifts there was an N x

2017-10-03 16:24:14 418

原创 Opposite Task

This problem gives you a flavor the concept of special judge. That means the judge is smart enough to verify your code even though it may print different results. In this problem you are asked to find

2017-10-03 14:47:50 584

原创 False Ordering

We define b is a Divisor of a number a if a is divisible by b. So, the divisors of 12 are 1, 2, 3, 4, 6, 12. So, 12 has 6 divisors.Now you have to order all the integers from 1 to 1000. x will come

2017-10-02 21:59:19 498

原创 Digits of Factorial

Factorial of an integer is defined by the following functionf(0) = 1f(n) = f(n - 1) * n, if(n > 0)So, factorial of 5 is 120. But in different bases, the factorial may be different. For example,

2017-10-02 18:08:34 433

原创 汉字统计

统计给定文本文件中汉字的个数。Input输入文件首先包含一个整数n,表示测试实例的个数,然后是n段文本。Output对于每一段文本,输出其中的汉字的个数,每个测试实例的输出占一行。 [Hint:]从汉字机内码的特点考虑~ Sample Input2WaHaHa! WaHaHa! 今年过节不说话要说只说普通话WaHaHa! WaHaHa!马上就要期末考试了Ar

2017-10-02 15:40:46 596

原创 首字母变大写

输入一个英文句子,将每个单词的第一个字母改成大写字母。 Input输入数据包含多个测试实例,每个测试实例是一个长度不超过100的英文句子,占一行。 Output请输出按照要求改写后的英文句子。 Sample Inputi like acmi want to get an acceptedSample OutputI Like AcmI Want To

2017-10-02 12:11:15 595

空空如也

空空如也

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

TA关注的人

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