`
bcyy
  • 浏览: 1830936 次
文章分类
社区版块
存档分类
最新评论
文章列表
You are given the whole numbersN,MandY. Write a program that will find all whole numbersXin the interval [0,M− 1] such thatXNmodM=Y. Input The input contains a single line withN,MandY(0<N<999, 1<M<999, 0<Y<999) separated with one space. Output Output all numbersX ...
On the Day of the Flag of Russia a shop-owner decided to decorate the show-window of his shop with textile stripes of white, blue and red colors. He wants to satisfy the following conditions: Stripes of the same color cannot be placed next to each other. A blue stripe must always be placed betw ...
收集的几个步态识别(Gait Recognition)相关的数据集: (转载请注明作者和出处:http://blog.csdn.net/xiaowei_cqu未经允许请勿用于商业用途)
Let's consider an infinite sequence of digits constructed of ascending powers of 10 written one after another. Here is the beginning of the sequence: 110100100010000… You are to find out what digit is located at the definite position of the sequence. Input There is the only integerNin t ...
题目意思: 就是要对角线扫描一个矩阵, 原题也很啰嗦: Ural doctors worry about the health of their youth very much. Special investigations showed that a lot of clever students instead of playing football, skating or bicycling had participated in something like Programming Olympiads. Moreover, they call it sports ...
原题链接:http://oj.leetcode.com/problems/construct-binary-tree-from-inorder-and-postorder-traversal/这道题和Construct Binary Tree from Preorder and Inorder Traversal思路完全一样,如果有朋友不了解,请先看看Construct Binary Tree from Preorder and Inorder Traversal哈。 ...
原题链接:http://oj.leetcode.com/problems/construct-binary-tree-from-preorder-and-inorder-traversal/这道题是树中比较有难度的题目,需要根据先序遍历和中序遍历来构造出树来。这道题看似毫无头绪,其实梳理一下还是有章可循的。下面我们就用一 ...
原题链接:http://oj.leetcode.com/problems/remove-duplicates-from-sorted-list-ii/这道题跟Remove Duplicates from Sorted List比较类似,只是这里要把出现重复的元素全部删除。其实道理还是一样,只是现在要把前驱指针指向上一个不重复的元素中,如果找到不重复元素,则把前驱指针知道该元素,否则删除此元素。算法只需要一遍扫描,时间复杂度是O(n),空间只需要几个辅助指针,是O(1)。代码如下:public ListNode deleteDuplicates(ListNode head) { if( ...
题意: 有一个巧克力由很多小方块组成,每次掰开一半,最后一次没巧克力掰的人算输(所有巧克力都被掰开成一个最小的方块了)。 Little Boy is mad at Karlsson, who ate all the sweets in the flat and even went to the neighbours to eat their sweets too. Now Little Boy's parents brought home a chocolate bar, and, sure enough, Karlsson is here already and wants ...
本题就是给出一个无穷大数,算其是否能被11除尽 Description Your job is, given a positive numberN, determine if it is a multiple of eleven. Input specification The input is a file such that each line contains a positive number. A line containing the number 0 is the end of the input. The given numbers c ...
很好玩的一道题,可以熟悉下位操作实现和玩一玩bitset这个容器 Description We define the parity of an integerNas the sum of the bits in binary representation computed modulo two. As an example, the number 21 = 10101 has three 1s in its binary representation so it has parity 3 (mod 2), or 1. In this problem you have ...
1049 - Sum Description Your task is to find the sum of all integer numbers lying between 1 andNinclusive. Input specification The input consists of a single integerNthat is not greater than 10^4 by it's absolute value. Output specification Write to the output a single inte ...
题目也挺难懂的,要仔细审题,其实就是一句话搞定的意思:把一组数组合成所有数值相等的一组新的数列。 看她题目说了一大堆: Description George took sticks of the same length and cut them randomly until all parts became at most 50 units long. ...
原题链接:http://oj.leetcode.com/problems/remove-duplicates-from-sorted-list/这是一道比较简单的链表操作的题目,要求是删去有序链表中重复的元素。方法比较清晰,维护两个指针,一个指向当前不重复的最后一个元素,一个进行依次扫描, ...
原题链接:http://oj.leetcode.com/problems/remove-duplicates-from-sorted-array-ii/这道题跟Remove Duplicates from Sorted Array比较类似,区别只是这里元素可以重复出现至多两次,而不是一次。其实也比较简单,只需要维护一个counter,当counter是2时,就直接跳过即可,否则说明元素出现次数没有超,继续放入结果数组,若遇到新元素则重置counter。总体算法只需要扫描一次数组,所以时间上是O(n),空间上只需要维护一个index和counter,所以是O(1)。代码如下:public in ...
Global site tag (gtag.js) - Google Analytics