PermutationsGiven a collection of numbers, return all possible permutations.For example,[1,2,3]have the following permutations:[1,2,3],[1,3,2],[2,1,3]...
分类:
其他好文 时间:
2014-09-24 04:02:35
阅读次数:
212
直接看代码就OK。思路比较简单。就是注意概率要在转移过程中算出来。不能算成成立的方案书除以总方案数(POJ的这道题可以这么干。数据很水么。另外POJ要用%.5f,%.5lf 会WA。)#include #include #include #include #include #include #i.....
分类:
其他好文 时间:
2014-09-23 20:45:55
阅读次数:
198
Given a collection of numbers that might contain duplicates, return all possible unique permutations.
For example,
[1,1,2] have the following unique permutations:
[1,1,2], [1,2,1],
and [2,1,1]....
分类:
其他好文 时间:
2014-09-23 17:07:24
阅读次数:
222
题目大意:费马定理:a^p = a(mod p) (a为大于1的整数,p为素数),一些非素数p,同样也符合上边的
定理,这样的p被称作基于a的伪素数,给你p和a,判断p是否是基于a的伪素数
思路:很简单的快速幂取余+素性判断
如果p为素数,则直接输出no
如果p不为素数,则进行快速幂取余判断是否为伪素数,若是,输出yes,不是,输出no...
分类:
其他好文 时间:
2014-09-23 08:30:34
阅读次数:
248
Given an array of integers, find two numbers such that they add up to a specific target number.The function twoSum should return indices of the two nu...
分类:
其他好文 时间:
2014-09-22 23:28:53
阅读次数:
160
【题目】
Given a binary tree containing digits from 0-9 only, each root-to-leaf
path could represent a number.
An example is the root-to-leaf path 1->2->3 which represents the number 123.
Fin...
分类:
其他好文 时间:
2014-09-22 19:30:53
阅读次数:
175
The kth great number
Xiao Ming and Xiao Bao are playing a simple Numbers game. In a round Xiao Ming can choose to write down a number, or ask Xiao Bao what the kth great number is. Because the numb...
分类:
其他好文 时间:
2014-09-22 19:12:13
阅读次数:
197
Where is the Marble?
Where is the Marble?
Raju and Meena love to play with Marbles. They have got a lot of marbles with numbers written on them. At the beginning, Raju wou...
分类:
其他好文 时间:
2014-09-22 01:04:21
阅读次数:
477
题目:找到用2,3,5,7为数的因第n个数字。
分析:dp,数据结构。类似于合并果子的队列维护,用4根指针分别指向队列,用当前的数乘以对应数字即可。
说明:(2011-09-19 01:42)
#include
using namespace std;
int F[ 5845 ];
int n[ 4 ] = {2,3,5,7};
int p[ 4 ];
int main()
{
...
分类:
其他好文 时间:
2014-09-21 23:57:21
阅读次数:
345
打表大军是一股邪恶势力→_→ 1 #include 2 #include 3 #include 4 #include 5 #include 6 #include 7 #include 8 #include 9 #include 10 #include 11 us...
分类:
其他好文 时间:
2014-09-21 19:25:51
阅读次数:
781