- 博客(168)
- 收藏
- 关注
原创 1046 Shortest Distance
解题思路:如果只是简单的记录各个点之间的距离,每次询问的时候进行计算的话,最后一个测试点会运行超时,于是就改成数组中记录的是,从一号点到当前点的总距离,查询的时候直接将距离相减就是正向的两个点之间的距离,反向的距离用总的环的距离减去正向两个点之间的距离就可,输出较小的距离。
2016-02-27 10:51:25
405
原创 1019 General Palindromic Number
A number that will be the same when it is written forwards or backwards is known as a Palindromic Number. For example, 1234321 is a palindromic number. All single digit numbers are palindromic numbers.
2016-02-27 10:30:07
356
原创 1015 Reversible Primes
A reversible prime in any number system is a prime whose “reverse” in that number system is also a prime. For example in the decimal system 73 is a reversible prime because its reverse 37 is also a pri
2016-02-27 10:03:19
357
原创 1023 Have Fun with Numbers
Notice that the number 123456789 is a 9-digit number consisting exactly the numbers from 1 to 9, with no duplication. Double it we will obtain 246913578, which happens to be another 9-digit number cons
2016-02-26 17:16:39
446
原创 1004 Counting Leaves
A family hierarchy is usually presented by a pedigree tree. Your job is to count those family members who have no child. InputEach input file contains one test case. Each case starts with a line conta
2016-02-26 16:55:09
298
原创 1097 Deduplication on a Linked List
Given a singly linked list L with integer keys, you are supposed to remove the nodes with duplicated absolute values of the keys. That is, for each value K, only the first node of which the value or ab
2016-02-26 15:52:43
348
原创 1098 Insertion or Heap Sort
According to Wikipedia:Insertion sort iterates, consuming one input element each repetition, and growing a sorted output list. Each iteration, insertion sort removes one element from the input data, fi
2016-02-26 15:10:59
461
原创 1099 Build A Binary Search Tree
A Binary Search Tree (BST) is recursively defined as a binary tree which has the following properties:The left subtree of a node contains only nodes with keys less than the node’s key. The right subtr
2016-02-26 12:54:26
280
原创 1094 The Largest Generation
A family hierarchy is usually presented by a pedigree tree where all the nodes on the same level belong to the same generation. Your task is to find the generation with the largest population.Input Spe
2016-02-26 11:00:20
440
原创 1102 Invert a Binary Tree
The following is from Max Howell @twitter:Google: 90% of our engineers use the software you wrote (Homebrew), but you can’t invert a binary tree on a whiteboard so fuck off.Now it’s your turn to prove
2016-02-25 16:49:43
429
原创 1101 Quick Sort
There is a classical process named partition in the famous quick sort algorithm. In this process we typically choose one element as the pivot. Then the elements less than the pivot are moved to its lef
2016-02-25 15:51:25
488
原创 1011 World Cup Betting
With the 2010 FIFA World Cup running, football fans the world over were becoming increasingly excited as the best players from the best teams doing battles for the World Cup trophy in South Africa. Sim
2016-02-25 15:35:45
366
原创 1107 Social Clusters
When register on a social network, you are always asked to specify your hobbies in order to find some potential friends with the same hobbies. A “social cluster” is a set of people who have some of the
2016-02-25 15:02:00
767
原创 mongodb 数据库操作
命令行切换到mongodb的bin目录下开启mongodb服务,然后在命令行中输入mongo进入mongodb数据库1.创建数据库use databasename切换到名字为databasename的数据库,如果在数据库不存在就创建一个2.插入数据db.user.insert({"name":"haha","password":"123456"})想user集合中插
2016-02-19 20:53:02
534
原创 1089 Insert or Merge
According to Wikipedia:Insertion sort iterates, consuming one input element each repetition, and growing a sorted output list. Each iteration, insertion sort removes one element from the input data, fi
2016-02-11 15:54:46
799
原创 python 使用requests第三方库自动登陆新浪微博
学习python的最初原因就是写爬虫,最近一直在写爬虫。感觉写爬虫的时候主要问题就是四个:页面分析,网站登录,反反爬虫,多线程并发。四个问题难度依次递增。刚开始的时候觉得页面分析挺没有头绪的,但是写过几次之后就有了套路,对页面中的自己感兴趣的内容的抓取也变得得心应手了。其次就是网站登录,这是写爬虫一定会遇到的问题,因为有些网站需要用户登录之后才可以查看,所以需要去分析网站的登录机制。难点在于,虽然
2016-02-10 10:46:10
5900
原创 python 多线程下载图片
接上一篇,因为图片量太大,所以试着用多线程来下载图片不知道会不会快一点,我将每个收藏夹内的所有图片的url放在url_list的列表中,然后将列表中的url分成100份,分配给100个线程同时下载,用切片来分割列表 尝试多线程的时候,发现线程数量不能过多,线程数量过多,程序会报内存错误兴趣是第一生产力#-*-coding:utf-8-*-import sysimport osimport S
2016-02-08 20:19:58
4139
原创 Python Requests爬虫——获取一个收藏夹下所有答案的图片
Spider.py#-*-coding:utf-8-*-import requestsfrom bs4 import BeautifulSoupimport timeimport jsonimport oshead ={'Accept':'*/*', 'Content-Type':'application/x-www-form-urlencoded; cha
2016-02-08 18:32:25
2348
原创 1238 Substrings
Problem Description You are given a number of case-sensitive strings of alphabetic characters, find the largest string X, such that either X, or its inverse can be found as a substring of any of the g
2016-02-07 13:47:27
409
原创 1047 Student List for Course
Zhejiang University has 40000 students and provides 2500 courses. Now given the registered course list of each student, you are supposed to output the student name lists of all the courses.Input S
2016-02-06 15:36:13
619
原创 1039 Course List for Student
Zhejiang University has 40000 students and provides 2500 courses. Now given the student name lists of all the courses, you are supposed to output the registered course list for each student who comes
2016-02-06 14:58:36
337
原创 android 传感器 光照传感器示例
android中使用每个传感器的方法都比较类似,所以拿简单的光照传感器作为例子。1.获取SensorManager SensorManager是系统所有传感器的管理器2.指定传感器的类型3.实现SensorEventListener接口4.调用SensorManager的registerListener()方法注册传感器5.调用SensorManager的unregis
2016-02-02 19:47:34
1393
原创 android 调用相机和获取相册图片
调用相机:takePhoto = (Button) findViewById(R.id.take_photo); takePhoto.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) {
2016-02-02 16:24:48
760
原创 1038 Recover the Smallest Number
Given a collection of number segments, you are supposed to recover the smallest number from them. For example, given {32, 321, 3214, 0229, 87}, we can recover many numbers such like 32-321-3214-0229-8
2016-02-01 19:24:26
446
原创 Android Activity活动生命周期
Android对Activity活动的管理,是将Acitivity放置在一个栈里,通过管理这个活动栈来管理所有的活动的状态。当新创建一个活动时,系统会将这个活动压入活动栈中,新创建的活动这时候处于栈顶位置,就属于运行的状态,可以被用户操作,当用户执行返回操作或者是结束操作是,系统将处于栈顶位置的活动出栈,活动结束,前一个入栈的活动处于栈顶位置,被展示给用户Activity活动在生命周期中一共有
2016-01-29 13:51:56
655
原创 python Requests 知乎问题图片爬虫
将相应问题出的数字改成想要爬取的问题的号码即可,将账号密码改成自己的#-*-coding:utf-8-*-import requestsimport timeimport jsonimport sysimport osfrom bs4 import BeautifulSoupreload(sys)sys.setdefaultencoding('utf-8')email =
2016-01-26 21:42:38
3067
原创 Python使用Requests第三方库自动登陆知乎
写爬虫就是我学习python的动力,刚开始学习的时候是用python自带的urllib和urllib2的库写爬虫,感觉有点繁琐,今天学习了Requests库感觉用起来比之前用的库方便多了。对网页的分析用的是BeautifulSoup4,之前用正则表达式写麻烦还伤脑经,有便利的工具于是就用了。准备工具:python2.7 RequestBeautiful第一步:分析登录请求
2016-01-23 20:32:12
9268
原创 Android 通知栏的使用
使用步骤第一步:创建一个NotificationManager来对所有的通知进行管理第二步:创建一个通知栏的Builder构造类第三步:通过对builder对象对通知栏进行设置第四步:
2016-01-22 20:33:43
753
原创 1105 Spiral Matrix
This time your job is to fill a sequence of N positive integers into a spiral matrix in non-increasing order. A spiral matrix is filled in from the first element at the upper-left corner, then move in
2016-01-05 21:34:15
566
原创 Android Studio 错误记录
java.lang.IllegalArgumentException: No config chosen01-05 05:31:52.408 2349-2462/com.baidu.test.baidu E/AndroidRuntime: FATAL EXCEPTION: GLThread 11001-05 05:31:52.408 2349-2462/com.baidu.test.baidu E/AndroidRuntime: java.lang.IllegalArgumentException:
2016-01-05 19:34:46
1549
原创 Android SQLite数据库 《第一行代码》
SQLite是Android自带的数据库,为了方便管理,Android提供了一个SQLiteOpenHelper的类来帮助管理数据库。但是SQLiteOpenHelper是一个抽象类,我们使用的时候需要创建自己的一个类去继承,并且实现抽象类中的两个方法onCreate()和onUpgrade()方法,onCreate()方法在创建数据库表的时候调用,onUpgrade()方法在更新数据库表到时候调
2015-12-28 17:41:48
1968
原创 1104 Sun of Number Segments
Given a sequence of positive numbers, a segment is defined to be a consecutive subsequence. For example, given the sequence {0.1, 0.2, 0.3, 0.4}, we have 10 segments: (0.1) (0.1, 0.2) (0.1, 0.2, 0.3) (
2015-12-28 10:15:56
449
原创 Android Broadcast广播机制 《第一行代码》
Android使用用广播来传递个接收信息,是在Intent上中更加灵活传播消息的一种机制。根据接收的方式可以分为两种广播形式,第一种是标准广播(Normal broadcast),这种广播发出之后,所有的能接受广播的接收器都能在同一时间接收到广播。还有一种就是有序广播,这种广播发出之后,首先是优先级最高的广播,接收到这一条广播信息,然后对这条信息处理之后发送给次优先级的广播接收器,也可以截断广播的
2015-12-24 14:26:17
789
原创 Android ListView的设计与使用 《第一行代码》
ListView原本是只能显示一段文本的,如果想要在ListView中显示更加丰富的内容就需要对ListView进行定制。假设要使得每个ListView子项显示水果图片和文字。简单的显示ListView使得每个子项左边显示图片,右边显示文字。定义一个实体类实体类中包含ListView子项所要显示的内容资源,比如新建一个Fruit类,有name和imageId两个属性,用于保存子项显示的内容。那么
2015-12-21 10:56:02
1524
原创 1024 Palindromic Number
A number that will be the same when it is written forwards or backwards is known as a Palindromic Number. For example, 1234321 is a palindromic number. All single digit numbers are palindromic numbers.
2015-12-17 09:54:44
411
原创 1042 Shuffling Machine
Shuffling is a procedure used to randomize a deck of playing cards. Because standard shuffling techniques are seen as weak, and in order to avoid "inside jobs" where employees collaborate with gambler
2015-12-15 21:40:31
401
原创 1041 Be Unique
Being unique is so important to people on Mars that even their lottery is designed in a unique way. The rule of winning is simple: one bets on a number chosen from [1, 104]. The first one who bets on
2015-12-15 21:38:29
508
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人
RSS订阅