题目上的X代表的未知数,不一定是同一个数字. 其实这道题,直接一推敲答案就出来了,首先,积德尾数是9,说明 X*(Y3 + Z)的值尾数是3,3的因子只有1和3,所以X只有1和3候选,但是题目说第一个肯定不是1,那就是3了. 那么括号里面Y3+Z的值就必然尾数是1,而能和3相加尾数是1的只有8,所以Z就是8了.这样就还剩下Y的值了,平方等于8000+的数字,一想大概是在90左右, 这样子,括号里面(Y3+Z)的值大概就框定在30左右,肯定比30大,但绝对不超过35,由于之前已经判断出Z是8,所以…
Given a string of numbers and operators, return all possible results from computing all the different possible ways to group numbers and operators. The valid operators are +, -and *. Example 1 Input: "2-1-1". ((2-1)-1) = 0 (2-(1-1)) = 2 Output: …
Given an array of n integers where n > 1, nums, return an array output such that output[i] is equal to the product of all the elements of nums except nums[i]. Solve it without division and in O(n). For example, given [1,2,3,4], return [24,12,8,6]. Fo…
clj在某场hihoCoder比赛中的一道题,表示clj的数学题实在6,这道图论貌似还算可以... 题目链接:http://hihocoder.com/problemset/problem/1167 由于是中文题目,题意不再赘述. 对于任意两条小精灵的活动路径a和b,二者相交的判断条件为b的两个端点的LCA在a的路径上:那么我们可以首先将每个活动路径端点的LCA离线预处理出来,对每个节点LCA值+1. 然后以某个节点(我选择的是节点1)为根进行深搜,算出一条从节点1到节点x的LCA值和,那么任意…
Boring Counting Time Limit: 3000ms   Memory limit: 65536K  有疑问?点这里^_^ 题目描述     In this problem you are given a number sequence P consisting of N integer and Pi is the ith element in the sequence. Now you task is to answer a list of queries, for each…
Joseph Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 1512    Accepted Submission(s): 948 Problem Description   The Joseph's problem is notoriously known. For those who are not familiar with th…
题意:已知D(0<=D<2^31).s1.s2,其中L为D转化为二进制数时1的个数,题目保证s1<=L<=s2,求一个数,满足以下条件: 1.比D大 2.转化为二进制时1的个数在[s1, s2]内 3.找出满足1.2条件的最小数字 分析: 1.首先将D加1,假设该数为x,求出x转化为二进制时1的个数cnt. 2.若s1<=cnt<=s2,则输出x 3.若cnt<s1,则应当增加1的数目,因为要保证找到的数字最小,所以要从二进制数的最右边开始改变. 方法:从右向左,…
Description 两个\(d\)维向量\(A=[a_{1},a_{2},...,a_{d}]\)与\(B=[b_{1},b_{2},...,b_{d}]\)的内积为其相对应维度的权值的乘积和,即: 现有\(n\)个\(d\)维向量\(x_{1},...,x_{n}\),小喵喵想知道是否存在两个向量的内积为\(k\)的倍数.请帮助她解决这个问题 Input 第一行包含\(3\)个正整数\(n,d,k\),分别表示向量的个数,维数以及待检测的倍数. 接下来\(n\)行每行有\(d\)个非负整数…
刷题备忘录,for bug-free leetcode 396. Rotate Function 题意: Given an array of integers A and let n to be its length. Assume Bk to be an array obtained by rotating the array A k positions clock-wise, we define a "rotation function" F on A as follow: F(k…
https://leetcode.com/problems/find-all-duplicates-in-an-array/description/ 参考:http://www.cnblogs.com/grandyang/p/4843654.html Given an array of integers, 1 ≤ a[i] ≤ n (n = size of array), some elements appear twice and others appear once. Find all th…