自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+

咸鱼塘

这是一个养鱼的水塘

  • 博客(16)
  • 资源 (1)
  • 收藏
  • 关注

原创 剑指Offer-Java-旋转数组的最小数字

题目把一个数组最开始的若干个元素搬到数组的末尾,我们称之为数组的旋转。 输入一个非减排序的数组的一个旋转,输出旋转数组的最小元素。 例如数组{3,4,5,1,2}为{1,2,3,4,5}的一个旋转,该数组的最小值为1。 NOTE:给出的所有元素都大于0,若数组大小为0,请返回0。代码只需要理解旋转数组的规律即可import java.util.ArrayList;public...

2018-08-30 22:21:24 136

原创 剑指Offer-Java-用两个栈实现队列

题目用两个栈来实现一个队列,完成队列的Push和Pop操作。 队列中的元素为int类型。代码只需要来回倒就可以实现了。import java.util.Stack;public class Solution { Stack<Integer> stack1 = new Stack<Integer>(); Stack<Integ...

2018-08-30 16:50:36 162

原创 剑指Offer-Java-重建二叉树

题目输入某二叉树的前序遍历和中序遍历的结果,请重建出该二叉树。假设输入的前序遍历和中序遍历的结果中都不含重复的数字。例如输入前序遍历序列{1,2,4,7,3,5,6,8}和中序遍历序列{4,7,2,1,5,3,8,6},则重建二叉树并返回。代码/** * Definition for binary tree * public class TreeNode { * ...

2018-08-30 16:06:29 133

原创 LeetCode-Java-893. Groups of Special-Equivalent Strings

题目You are given an array A of strings.Two strings S and T are special-equivalent if after any number of moves, S == T.A move consists of choosing two indices i and j with i % 2 == j % 2, and s...

2018-08-29 16:26:46 555

原创 LeetCode-Java-575. Distribute Candies

题目Given an integer array with even length, where different numbers in this array represent different kinds of candies. Each number means one candy of the corresponding kind. You need to distribute...

2018-08-29 12:19:33 191

原创 LeetCode-Java-766. Toeplitz Matrix

题目A matrix is Toeplitz if every diagonal from top-left to bottom-right has the same element.Now given an M x N matrix, return True if and only if the matrix is Toeplitz.Example 1:Input:mat...

2018-08-26 10:31:26 227

原创 LeetCode-Java-872. Leaf-Similar Trees

题目Consider all the leaves of a binary tree. From left to right order, the values of those leaves form a leaf value sequence.假装有图For example, in the given tree above, the leaf value sequence i...

2018-08-22 12:58:34 209 2

原创 LeetCode-Java-136. Single Number

题目Given a non-empty array of integers, every element appears twice except for one. Find that single one.Note:Your algorithm should have a linear runtime complexity. Could you implement it with...

2018-08-19 16:56:23 263

原创 LeetCode-Java-559. Maximum Depth of N-ary Tree

题目Given a n-ary 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.For example, given a 3-ary tree:...

2018-08-19 15:30:30 387

原创 LeetCode-SQL-620. Not Boring Movies

题目X city opened a new cinema, many people would like to go to this cinema. The cinema also gives out a poster indicating the movies’ ratings and descriptions.Please write a SQL query to output mo...

2018-08-19 14:32:45 202

原创 LeetCode-Java-344. Reverse String

题目Write a function that takes a string as input and returns the string reversed.Example 1:Input: "hello"Output: "olleh"Example 2:Input: "A man, a plan, a canal: Panama"Output: "amanaP :la...

2018-08-19 14:18:55 280

原创 LeetCode-Java-557. Reverse Words in a String III

题目Given a string, you need to reverse the order of characters in each word within a sentence while still preserving whitespace and initial word order.Example 1:Input: "Let's take LeetCode conte...

2018-08-19 13:46:10 299

原创 LeetCode-Java-821. Shortest Distance to a Character

题目Given a string S and a character C, return an array of integers representing the shortest distance from the character C in the string.Example 1:Input: S = "loveleetcode", C = 'e'Output: [3,...

2018-08-19 13:15:31 302

原创 LeetCode-Java-884. Uncommon Words from Two Sentences

题目We are given two sentences A and B. (A sentence is a string of space separated words. Each word consists only of lowercase letters.)A word is uncommon if it appears exactly once in one of th...

2018-08-18 10:22:05 455

原创 LeetCode-Java-811. Subdomain Visit Count

题目A website domain like "discuss.leetcode.com" consists of various subdomains. At the top level, we have "com", at the next level, we have "leetcode.com", and at the lowest level, "discuss.leetcod...

2018-08-18 09:44:27 314

原创 LeetCode-Java-876. Middle of the Linked List

题目Given a non-empty, singly linked list with head node head, return a middle node of linked list.If there are two middle nodes, return the second middle node.Example 1:Input: [1,2,3,4,5]O...

2018-08-02 10:02:40 395

中兴捧月-数字化婚姻配对尝试

一、标题: 数字化婚姻配对尝试 二、题目: 建立一个模型,来模拟推导社会男女择偶过程。 为了模型简化,一个人的特性指标有三个,这里假设为财富、样貌、品格,每个指标均可取值1-100之间任意数字。同样也对这3项指标有自己的需求。这3个需求值取值范围都在1-98间,当然三者的和必须为100.所以任意一个人可以用以下数组来表述: G(A、B、C、A1、B1、C1)G代表男,M代表女。 举例G11(80、50、40、10、30、60),表示男11号,拥有财富80、样貌50、品格40,对异性品格的偏好为:财富在乎程度百分之10、样貌在乎程度百分之30、品格在乎程度百分之60。 同样为了模型简化,假设信息是完全对称的,即是说,每个人都能一眼就能看清楚任意一个人的财富、样貌、品格。 还是为了模型简化,我建模所用样本为男女各100个,即男女人数相同。 每个人对异性的满意度将如下定义:每个偏好指标与异性的对应的禀赋指标相乘,三个指标的乘积再相加,即他(她)对某个异性的满意度。 举例G11(80、50、40、10、30、60)对M(50、60、80、40、10、50)的满意度为: (10*50+30*60+60*80)= 7100分 相对的 MM 对 GG的满意度则为: (40*80+10*50+50*40) = 5700分 好了,配对活动开始,设计的配对法则如下: 1、100个男方,顺序,轮流从0号到99号女方中挑选自己最满意的一位,然后向她发出配对邀请。 2、接受邀请最多的女方开始行动,对这些邀请的男性中,选择最满意的一位。 3、那么这两位配对成功,剔除出样本,剩下的99对继续这样配对。 4、循环该配对法则,直到最后一对男女配对成功。 三、初赛阶段要求: 1、编程语言为java,C++或C语言任意一种;运行环境windows。 2、能让用户输入自己的参数以及对各项数值的偏好,然后随机生成100位男性100位女性(包括用户在内。如果用为男性则为99男100女),数值全部随机但需满足题设限制。按照上述规则给出一个匹配结果呈现给用户。 3、若采用c/c++,要输出可执行程序;若采用java,给出jar和bat。 4、在匹配时,如果发现有多个满意度相同的对象,要求自身三个属性(财富,外貌,品格)总和大的优先,如果再相同则id小的优先。如果有2位女士的选票相同,优先级规则同上。请把主角的id置为最小值,以便在前2个条件相同情况下,主角可以优先选择。 5、程序读取指定的配置文件,获取样本,然后根据指定的输入,输出结果。同时会给出一组源数据和标准答案给学生自测。最后再让学生根据不同的,指定的输入,给出考试答案。 请点击下载配置文件附件。附件中,male.txt,female.txt,players.txt 分别是男士样本、女士样本和主角样本各 100位。 男女样本中,每行都代表一位男士或女士的基本属性,从左到右依次是ID, 样貌,品格,财富 , 期望样貌,期望品格,期望财富,没有加入性别,需要在解析时手动添加,每个txt文本的性别都是一样的,请注意。另外,主角样本中没有ID属性,换成了性别属性,其中 0表示女性,1表示男性,其余属性依次为样貌,品格,财富,期望样貌 ,期望品格,期望财富。建议把主角的id都设置为 -1,以便满足优先选择的条件。 给出标准答案2组,用于考生自测: 1号主角(文本第一行),选择的对象属性为(6,18,82,87,3,10) 2号主角(文本第二行),选择的对象属性为(27,74,22,22,58,20) 同时要求考生输出9号主角(0,72,55,53,8,87,5),19号主角(0,11,4,63,22,60,18),47号主角(1,19,8,21,1,53,46),83号主角(1,23,11,17,58,31,11),99号主角(1,26,66,1,78,11,11)以及100号主角(0,68,28,19,43,11,46)的选择结果。 四、初赛阶段审核标准及评价细则 1. 功能分(40分) 如果学生最后答案错误,则该项得0分 如果答案正确,得40分 2. 代码质量分(30分) 可读性,整洁性,健壮性,可扩展性,封装性 3. 用户体验(10分) 界面美观,操作方便,有必要的信息提示 4. 代码文档质量(10分) 代码清晰,易读,注释完整 5. 单元测试(10分) 关键函数或容易出错部分应该有单元测试保证

2018-07-03

空空如也

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

TA关注的人

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