- 博客(69)
- 收藏
- 关注
原创 1032. 挖掘机技术哪家强(20)--做题记录
1032. 挖掘机技术哪家强(20)时间限制 200 ms内存限制 65536 kB代码长度限制 8000 B判题程序 Standard 作者 CHEN, Yue为了用事实说明挖掘机技术到底哪家强,PAT组织了一场挖掘机技能大赛。现请你根据比赛结果统计出技术最强的那个学校。输入格式:输入
2016-08-15 16:58:45
512
原创 1030. 完美数列(25)--做题记录
1030. 完美数列(25)::KMP给定一个正整数数列,和正整数p,设这个数列中的最大值是M,最小值是m,如果M 现在给定参数p和一些正整数,请你从中选择尽可能多的数构成一个完美数列。输入格式:输入第一行给出两个正整数N和p,其中N(5)是输入的正整数的个数,p(9)是给定的参数。第二行给出N个正整数,每个数不超过109。输出格式:在一行中输出最多可以选择多少个数可以
2016-08-11 17:59:38
328
原创 1029. 旧键盘(20)--做题记录
1029. 旧键盘(20)旧键盘上坏了几个键,于是在敲一段文字的时候,对应的字符就不会出现。现在给出应该输入的一段文字、以及实际被输入的文字,请你列出肯定坏掉的那些键。输入格式:输入在2行中分别给出应该输入的文字、以及实际被输入的文字。每段文字是不超过80个字符的串,由字母A-Z(包括大、小写)、数字0-9、以及下划线“_”(代表空格)组成。题目保证2个字符串均非空。输出格式:
2016-08-11 16:48:40
507
原创 1028. 人口普查(20)--做题记录
1028. 人口普查(20)某城镇进行人口普查,得到了全体居民的生日。现请你写个程序,找出镇上最年长和最年轻的人。这里确保每个输入的日期都是合法的,但不一定是合理的——假设已知镇上没有超过200岁的老人,而今天是2014年9月6日,所以超过200岁的生日和未出生的生日都是不合理的,应该被过滤掉。输入格式:输入在第一行给出正整数N,取值在(0, 105];随后N行,每行给出1个人
2016-08-05 23:34:59
589
原创 1027. 打印沙漏(20)--做题记录
1027. 打印沙漏(20)时间限制 200 ms内存限制 65536 kB代码长度限制 8000 B判题程序 Standard 作者 CHEN, Yue本题要求你写个程序把给定的符号打印成沙漏的形状。例如给定17个“*”,要求按下列格式打印***** *** * ********
2016-08-03 20:40:07
433
原创 1026. 程序运行时间(15)--做题记录
1026. 程序运行时间(15)要获得一个C语言程序的运行时间,常用的方法是调用头文件time.h,其中提供了clock()函数,可以捕捉从程序开始运行到clock()被调用时所耗费的时间。这个时间单位是clock tick,即“时钟打点”。同时还有一个常数CLK_TCK,给出了机器时钟每秒所走的时钟打点数。于是为了获得一个函数f的运行时间,我们只要在调用f之前先调用clock(),获得一
2016-08-01 23:24:39
1153
原创 1025. 反转链表 (25)--做题记录
1025. 反转链表 (25)给定一个常数K以及一个单链表L,请编写程序将L中每K个结点反转。例如:给定L为1→2→3→4→5→6,K为3,则输出应该为3→2→1→6→5→4;如果K为4,则输出应该为4→3→2→1→5→6,即最后不到K个元素不反转。输入格式:每个输入包含1个测试用例。每个测试用例第1行给出第1个结点的地址、结点总个数正整数N(5)、以及正整数K(接下来有N行,
2016-07-31 00:39:13
404
原创 1024. 科学计数法 (20)--做题记录
1024. 科学计数法 (20)科学计数法是科学家用来表示很大或很小的数字的一种方便的方法,其满足正则表达式[+-][1-9]"."[0-9]+E[+-][0-9]+,即数字的整数部分只有1位,小数部分至少有1位,该数字及其指数部分的正负号即使对正数也必定明确给出。现以科学计数法的格式给出实数A,请编写程序按普通数字表示法输出A,并保证所有有效位都被保留。输入格式:每个输入包含
2016-07-28 02:17:03
428
原创 1023. 组个最小数 (20)--做题记录
1023. 组个最小数 (20)给定数字0-9各若干个。你可以以任意顺序排列这些数字,但必须全部使用。目标是使得最后得到的数尽可能小(注意0不能做首位)。例如:给定两个0,两个1,三个5,一个8,我们得到的最小的数就是10015558。现给定数字,请编写程序输出能够组成的最小的数。输入格式:每个输入包含1个测试用例。每个测试用例在一行中给出10个非负整数,顺序表示我们拥有数
2016-07-27 13:29:37
644
原创 1022. D进制的A+B (20)--做题记录
1022. D进制的A+B (20)输入两个非负10进制整数A和B(30-1),输出A+B的D (1 输入格式:输入在一行中依次给出3个整数A、B和D。输出格式:输出A+B的D进制数。输入样例:123 456 8输出样例:1103#include using namespace std;long N, radixOri;void printR
2016-07-26 19:13:34
366
原创 1021. 个位数统计 (15)--做题记录
1021. 个位数统计 (15)给定一个k位整数N = dk-1*10k-1 + ... + d1*101 + d0 (0ik-1>0),请编写程序统计每种不同的个位数字出现的次数。例如:给定N = 100311,则有2个0,3个1,和1个3。输入格式:每个输入包含1个测试用例,即一个不超过1000位的正整数N。输出格式:对N中每一种不同的个位数字,以D:M的格式在一行中输
2016-07-26 13:29:49
319
原创 1020. 月饼 (25) -- 做题记录
1020. 月饼 (25)月饼是中国人在中秋佳节时吃的一种传统食品,不同地区有许多不同风味的月饼。现给定所有种类月饼的库存量、总售价、以及市场的最大需求量,请你计算可以获得的最大收益是多少。注意:销售时允许取出一部分库存。样例给出的情形是这样的:假如我们有3种月饼,其库存量分别为18、15、10万吨,总售价分别为75、72、45亿元。如果市场的最大需求量只有20万吨,那么我们最大收益策
2016-07-24 17:14:36
380
原创 1019. 数字黑洞 (20)--做题记录
1019. 数字黑洞 (20)给定任一个各位数字不完全相同的4位正整数,如果我们先把4个数字按非递增排序,再按非递减排序,然后用第1个数字减第2个数字,将得到一个新的数字。一直重复这样做,我们很快会停在有“数字黑洞”之称的6174,这个神奇的数字也叫Kaprekar常数。例如,我们从6767开始,将得到7766 - 6677 = 10899810 - 0189 = 9621
2016-07-24 16:13:07
990
原创 1018. 锤子剪刀布 (20)--刷题记录
1018. 锤子剪刀布 (20)时间限制 100 ms内存限制 65536 kB代码长度限制 8000 B判题程序 Standard 作者 CHEN, Yue大家应该都会玩“锤子剪刀布”的游戏:两人同时给出手势,胜负规则如图所示:现给出两人的交锋记录,请统计双方的胜、平、负次数,并且给出
2016-07-23 16:49:53
2541
原创 141. Linked List Cycle--LeetCode Record
Given a linked list, determine if it has a cycle in it./** * Definition for singly-linked list. * struct ListNode { * int val; * ListNode *next; * ListNode(int x) : val(x), next(NULL)
2016-07-20 09:31:28
195
原创 1017. A除以B (20)--做题纪录
1017. A除以B (20)时间限制100 ms内存限制65536 kB代码长度限制8000 B判题程序Standard作者CHEN, Yue本题要求计算A/B,其中A是不超过1000位的正整数,B是1位正整数。你需要输出商数Q和余数R,使得A =
2016-07-19 17:10:26
293
原创 1016. 部分A+B (15)--刷题纪录
1016. 部分A+B (15)时间限制100 ms内存限制65536 kB代码长度限制8000 B判题程序Standard作者CHEN, Yue正整数A的“DA(为1位整数)部分”定义为由A中所有DA组成的新整数PA。例如:给定A = 3862767
2016-07-19 16:09:59
744
原创 1014. 福尔摩斯的约会 (20)--做题纪录
1014. 福尔摩斯的约会 (20)时间限制100 ms内存限制65536 kB代码长度限制8000 B判题程序Standard作者CHEN, Yue大侦探福尔摩斯接到一张奇怪的字条:“我们约会吧! 3485djDkxh4hhGE 2984akDfkk
2016-07-19 15:58:43
555
原创 1015. 德才论 (25)--刷题纪录
1015. 德才论 (25)时间限制200 ms内存限制65536 kB代码长度限制8000 B判题程序Standard作者CHEN, Li宋代史学家司马光在《资治通鉴》中有一段著名的“德才论”:“是故才德全尽谓之圣人,才德兼亡谓之愚人,德胜才谓之君子
2016-07-19 15:54:25
558
原创 121. Best Time to Buy and Sell Stock--LeetCode Record
Say you have an array for which the ith element is the price of a given stock on day i. If you were only permitted to complete at most one transaction (ie, buy one and sell one share of the stock)
2016-07-18 22:18:21
230
原创 83. Remove Duplicates from Sorted List--LeetCode Record
Given a sorted linked list, delete all duplicates such that each element appear only once. For example, Given 1->1->2, return 1->2. Given 1->1->2->3->3, return 1->2->3. func deleteDuplic
2016-07-17 11:12:09
211
原创 263. Ugly Number--LeetCode Record
Write a program to check whether a given number is an ugly number. Ugly numbers are positive numbers whose prime factors only include 2, 3, 5. For example, 6, 8 are ugly while 14 is not ugly since
2016-07-17 10:53:16
246
原创 235. Lowest Common Ancestor of a Binary Search Tree --LeetCode Record
Given a binary search tree (BST), find the lowest common ancestor (LCA) of two given nodes in the BST. According to the definition of LCA on Wikipedia: “The lowest common ancestor is defined betwe
2016-07-17 01:31:01
210
原创 202. Happy Number --LeetCode Record
Write an algorithm to determine if a number is “happy”. A happy number is a number defined by the following process: Starting with any positive integer, replace the number by the sum of the square
2016-07-17 01:13:46
205
原创 191. Number of 1 Bits--LeetCode Record
Write a function that takes an unsigned integer and returns the number of ’1’ bits it has (also known as the Hamming weight). For example, the 32-bit integer ’11’ has binary representation 0000000
2016-07-14 16:38:17
231
原创 231. Power of Two--LeetCode Record
Given an integer, write a function to determine if it is a power of two.水到家了! func isPowerOfTwo(n: Int) -> Bool { return ( n > 0 && 1073741824 % n == 0); }
2016-07-14 16:11:45
195
原创 326. Power of Three--LeetCode Record
Given an integer, write a function to determine if it is a power of three. Follow up: Could you do it without using any loop / recursion?水! func isPowerOfThree(n: Int) -> Bool { //
2016-07-14 15:55:47
158
原创 350. Intersection of Two Arrays II--LeetCode Record
Given two arrays, write a function to compute their intersection. Example: Given nums1 = [1, 2, 2, 1], nums2 = [2, 2], return [2, 2]. Note: Each element in the result should appear as m
2016-07-14 15:09:15
155
原创 206. Reverse Linked List--LeetCode Record
Reverse a singly linked list./** * Definition for singly-linked list. * public class ListNode { * public var val: Int * public var next: ListNode? * public init(_ val: Int) { *
2016-07-14 00:55:22
188
原创 13. Roman to Integer--LeetCode Record
Given a roman numeral, convert it to an integer. Input is guaranteed to be within the range from 1 to 3999. let record:[Character:Int] = ["M": 1000, "D": 500, "C": 100, "L": 50, "X": 10, "V":
2016-07-14 00:26:49
200
原创 217. Contains Duplicate--LeetCode Record
Given an array of integers, find if the array contains any duplicates. Your function should return true if any value appears at least twice in the array, and it should return false if every element is
2016-07-13 00:33:43
179
原创 169. Majority Element--LeetCode Record
Given an array of size n, find the majority element. The majority element is the element that appears more than ⌊ n/2 ⌋ times. You may assume that the array is non-empty and the majority element a
2016-07-12 23:38:58
232
原创 171. Excel Sheet Column Number--LeetCode Record
Related to question Excel Sheet Column Title Given a column title as appear in an Excel sheet, return its corresponding column number. For example:A -> 1B -> 2C -> 3...Z -> 26AA -> 27A
2016-07-11 17:05:37
205
原创 242. Valid Anagram--LeetCode Record
Given two strings s and t, write a function to determine if t is an anagram of s. For example, s = “anagram”, t = “nagaram”, return true. s = “rat”, t = “car”, return false.class Solution {
2016-07-11 16:01:52
200
原创 100. Same Tree--LeetCode Record
Given two binary trees, write a function to check if they are equal or not. Two binary trees are considered equal if they are structurally identical and the nodes have the same value./** * Defin
2016-07-10 21:24:16
219
原创 237. Delete Node in a Linked List--LeetCode Record
Write a function to delete a node (except the tail) in a singly linked list, given only access to that node. Supposed the linked list is 1 -> 2 -> 3 -> 4 and you are given the third node with valu
2016-07-10 13:11:43
209
原创 349. Intersection of Two Arrays--LeetCode Record
Given two arrays, write a function to compute their intersection. Example: Given nums1 = [1, 2, 2, 1], nums2 = [2, 2], return [2]. Note: Each element in the result must be unique. Th
2016-07-10 02:02:20
229
原创 283. Move Zeroes--LeetCode Record
Given an array nums, write a function to move all 0’s to the end of it while maintaining the relative order of the non-zero elements. For example, given nums = [0, 1, 0, 3, 12], after calling your
2016-07-10 00:18:20
211
原创 226. Invert Binary Tree--LeetCode Record
/** * Definition for a binary tree node. * public class TreeNode { * public var val: Int * public var left: TreeNode? * public var right: TreeNode? * public init(_ val: Int) { *
2016-07-08 23:05:13
306
原创 104. Maximum Depth of Binary Tree--LeetCode Record
Given a binary tree, find its maximum depth. The maximum depth is the number of nodes along the longest path from the root node down to the farthest leaf node./** * Definition for a binary tree
2016-07-08 02:11:51
234
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人