题意:求一个b数组,b数组中的所有数互质,和a数组对应下标的数的差的绝对值最小。
考虑a数组中的所有数范围为[1,30]则,b数组取值只有可能为[1,59),因为如果取到59及其以后,肯定可以取1,59-30=30-1;而且1可以取多次,1与任何数互质。
然后首先需要把[2,59)之间的素数取出来,总共16个。然后状压,1代表那一位的素数因子是否存在。
d[i][s][0]表示递推到第i个位...
分类:
其他好文 时间:
2014-08-05 19:34:22
阅读次数:
271
/*Elevator
The highest building in our city has only one elevator. A request list is made up with N positive numbers. The numbers denote at which floors the elevator will stop, in specified order. It...
分类:
其他好文 时间:
2014-08-05 19:23:40
阅读次数:
209
IntroductionWith java.SizeOf you can measure the real memory size of your Java objects.Download it hereThe project is a little java agent what use the...
分类:
编程语言 时间:
2014-08-05 15:19:29
阅读次数:
200
题目链接题意 : 一个m面的骰子,掷n次,问得到最大值的期望。思路 : 数学期望,离散时的公式是E(X) = X1*p(X1) + X2*p(X2) + …… + Xn*p(Xn)p(xi)的是所有最大值是xi的情况数/总情况数一共是m^n种,掷n次,所有最大值是xi的情况数应该是xi^n,但是这里...
分类:
其他好文 时间:
2014-08-05 10:44:59
阅读次数:
217
题目:Given a binary tree, return the level order traversal of its nodes' values. (ie, from left to right, level by level).For example:Given binary tree....
分类:
编程语言 时间:
2014-08-05 05:18:28
阅读次数:
242
题目:Given a binary tree, return the bottom-up level order traversal of its nodes' values. (ie, from left to right, level by level from leaf to root).F....
分类:
编程语言 时间:
2014-08-05 05:18:08
阅读次数:
340
题目:Given a binary tree, return the zigzag level order traversal of its nodes' values. (ie, from left to right, then right to left for the next level ....
分类:
编程语言 时间:
2014-08-05 05:17:38
阅读次数:
311
An example of in-order traversal application. My intuition is that, we have to serialize it into an array and check, but in-order traversal does exact...
分类:
其他好文 时间:
2014-08-05 03:03:48
阅读次数:
241
题目原文:
You are given two linked lists representing two non-negative numbers. The digits are stored in reverse order and each of their nodes contain a single digit. Add the two numbers and return it ...
分类:
其他好文 时间:
2014-08-05 00:51:58
阅读次数:
257
Given a binary tree, return the zigzag level order traversal of its nodes' values. (ie, from left to right, then right to left for the next level and ...
分类:
其他好文 时间:
2014-08-05 00:18:28
阅读次数:
225