自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+

Win_Man的专栏

心有猛虎,细嗅蔷薇

  • 博客(34)
  • 收藏
  • 关注

原创 1048 Find Coins

解题思路:真的是PAT虐我千百遍,我待PAT如初恋,很简单的一道题,开一个面值的数组,已面值为数组下标,存放该面值的硬币的数量,然后从i=1开始遍历,看m-i的面值的硬币是否存在,如果存在,直接输出就好了,需要考虑输出两个面值一样的硬币的情况。!!!重点来了!!!题目中说>The second line contains N face values of the coins, which are all po

2016-02-29 14:14:33 368

原创 1032 Sharing

解题思路:可能不止有两个单词的节点,可能存在一些混淆点,所以使用了标记数组,从root1开始遍历,将单词一所有的节点进行标记,然后从root2开始进行遍历,遇到节点是已经被标记过的,那就记下地址,然后跳出循环。最后输出结果。

2016-02-28 20:27:45 525

原创 1052 Linked List Sorting

解题思路:注意两个情况:不知一条链表,还有链表为空的情况,所以next属性是有用的。

2016-02-28 20:05:05 388

原创 1078 Hashing

解题思路:坑爹的二次探测,一开始以为是一道很简单的题,结果还是被坑了,完全没有注意到冲撞处理策略,所以最后一个点一直过不了,后来看了别人的博客说要经过二次探测检测之后还是不能插入才输出“-”,不是一开始不能插入就直接输出“-”。too young二次冲撞检测就是,在i位置无法插入的情况下,进行i+1^2,i+2^2,i+3^2....依次递增的位置检测,如果检测到可以插入那就插入,一直找不到才输出“-”,网上别人定

2016-02-28 19:31:38 532

原创 1079 Total Sales of Supply Chain

A supply chain is a network of retailers(零售商), distributors(经销商), and suppliers(供应商)– everyone involved in moving a product from supplier to customer.Starting from one root supplier, everyone on the ch

2016-02-28 18:29:54 637

原创 1106 Lowest Price in Supply Chain

解题思路:简单的广搜,当搜索到某一层有零售商的时候就停止搜索,但是要记录那一层所有零售商的数量。要测试root直接为零售商的结果,一开始没有想到,导致测试点1一直运行超时,因为死循环了

2016-02-28 10:12:02 660

原创 1044 Shopping in Mars

解题思路:看到题目很顺手就写下来了,一提交,两个运行超时,一个内存超限,果然题目没那么简单,想了各种优化,没什么想法,网上找了一下都说是要二分,不想用二分,于是继续找,终于找到一篇文章是从n*n的复杂度上进行优化,用到了几个点是我没考虑到的。1.当i~j的区间上的和等于m之后,i+1~j区间上的情况就不用考虑了2.对于找不到等于m的情况,在找到某个区间i~j之和大于m之后,就可以跳出j的循环,从i+1为起点的区间

2016-02-27 21:17:12 546

原创 1075 PAT Judge

1.首先是没有提交和虽然提交过但是所有提交都是未通过编译的用户不用显示2.一道题如果只被未通过编译的提交过,那么最后显示的分数应该是03.一道题如果没有被提交过显示的才是-4.一道题如果已经通过编译提交过,后面可能还会有未通过编译的提交,需要考虑,不能覆盖结果5.多次满分提交的情况也需要考虑

2016-02-27 18:28:25 457

原创 1090 Higest Price in Supply Chain

解题思路:根据输入构建一棵树,然后找一下树的最大深度

2016-02-27 15:18:10 478

原创 1077 Kuchiguse

解题思路:英语差是硬伤啊,做成了求最长公共字串,结果发现只是求最长的末尾后缀。

2016-02-27 14:34:08 371

原创 1046 Shortest Distance

解题思路:如果只是简单的记录各个点之间的距离,每次询问的时候进行计算的话,最后一个测试点会运行超时,于是就改成数组中记录的是,从一号点到当前点的总距离,查询的时候直接将距离相减就是正向的两个点之间的距离,反向的距离用总的环的距离减去正向两个点之间的距离就可,输出较小的距离。

2016-02-27 10:51:25 367

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

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

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

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

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

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

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

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

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

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

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

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

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

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

原创 python 使用requests第三方库自动登陆新浪微博

学习python的最初原因就是写爬虫,最近一直在写爬虫。感觉写爬虫的时候主要问题就是四个:页面分析,网站登录,反反爬虫,多线程并发。四个问题难度依次递增。刚开始的时候觉得页面分析挺没有头绪的,但是写过几次之后就有了套路,对页面中的自己感兴趣的内容的抓取也变得得心应手了。其次就是网站登录,这是写爬虫一定会遇到的问题,因为有些网站需要用户登录之后才可以查看,所以需要去分析网站的登录机制。难点在于,虽然

2016-02-10 10:46:10 5790 2

原创 python 多线程下载图片

接上一篇,因为图片量太大,所以试着用多线程来下载图片不知道会不会快一点,我将每个收藏夹内的所有图片的url放在url_list的列表中,然后将列表中的url分成100份,分配给100个线程同时下载,用切片来分割列表 尝试多线程的时候,发现线程数量不能过多,线程数量过多,程序会报内存错误兴趣是第一生产力#-*-coding:utf-8-*-import sysimport osimport S

2016-02-08 20:19:58 4048

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

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

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

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

原创 android 传感器 光照传感器示例

android中使用每个传感器的方法都比较类似,所以拿简单的光照传感器作为例子。1.获取SensorManager     SensorManager是系统所有传感器的管理器2.指定传感器的类型3.实现SensorEventListener接口4.调用SensorManager的registerListener()方法注册传感器5.调用SensorManager的unregis

2016-02-02 19:47:34 1330

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

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

空空如也

空空如也

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

TA关注的人

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