r*******n 发帖数: 3020 | 1 vector wordBreak(string s, unordered_set &dict) {
// Note: The Solution object is instantiated only once and is reused
by each test case.
vector result;
int n = s.size();
vector> table(n, vector(n,false));
int max_len=0;
for(auto& word:dict){
if(max_len
max_len=word.size();
}
//DP
for(int i=0; i
for(int j=i;j阅读全帖 |
|
r*******n 发帖数: 3020 | 2 多谢,改了后过了OJ。
如你所说,我加了1-D bool table来记录有没有解
后面DFS根据这个如果没有解就停止递归搜索
把整个code贴下面
vector wordBreak(string s, unordered_set &dict) {
// Note: The Solution object is instantiated only once and is reused
by each test case.
vector result;
int n = s.size();
vector> table(n, vector(n,false));
int max_len=0;
for(auto& word:dict){
if(max_len
max_len=word.size();
}
... 阅读全帖 |
|
m********l 发帖数: 791 | 3 了解这题DFS的话代码简洁而且大测试不超时。
就是想拿这题练习一下BFS的解法,自己吭哧吭哧写的代码超时了,不知道代码中的哪
一步太耗时?大家帮忙看一下,谢谢~
或者其他可以改进的地方大家也不妨指出~
代码如下:
public class Solution {
public static Queue queue = new LinkedList();
public boolean exist(char[][] board, String word) {
if (word.equals("") || word == null)
return true;
if (board == null || board.length == 0)
return false;
int row = board.length;
int col = board[0].length;
String tmp = word; // save c... 阅读全帖 | | |
|
f**********t 发帖数: 1001 | 4 int harryPotterGrid(vector &grid, size_t col) {
if (grid.empty() || col == 0) {
return 0;
}
size_t row = grid.size() / col;
if (row == 0) {
return 0;
}
vector strengths(grid.size());
strengths[row * col - 1] = 0;
for (size_t i = row - 1; ; --i) {
for (size_t k = col - 1; ; --k) {
size_t x = i * col + k;
if (i + 1 != row) {
size_t xx = (i + 1) * col + k;
strengths[x] = 1 + strengths[xx] - grid[xx];
}
if (k + 1 != col) {... 阅读全帖 |
|
|
g***j 发帖数: 1275 | 6 Surrounded Regions ,就是把所有的不与边界相连的一大片O 转换成X
大家帮我看看这段code 哪儿错了? 大集合过不了
class Solution {
public:
void solve(vector> &board) {
// Start typing your C/C++ solution below
// DO NOT write int main() function
int row = board.size();
if(row == 0) return;
int col = board[0].size();
if(col == 0) return;
for(int i = 0; i < col; i++) {
flooding(board, 0, i);
flooding(board, r... 阅读全帖 |
|
p****e 发帖数: 3548 | 7 改成这样就可以了
class Solution {
public:
int row, col;
void solve(vector> &board) {
// Start typing your C/C++ solution below
// DO NOT write int main() function
row = board.size();
if(row == 0) return;
col = board[0].size();
if(col == 0) return;
for(int i = 0; i < col; i++) {
flooding(board, 0, i);
flooding(board, row-1, i);
}
for(int i = ... 阅读全帖 |
|
f**********t 发帖数: 1001 | 8 写个暴力的,要求状态DP的地方高攀不起
void NumOfBoardLayouts(vector> &board, size_t x, size_t y, int
*res) {
//for 1 * 2 board
size_t row = board.size();
size_t col = board[0].size();
if (x == row) {
++*res;
return;
}
for (size_t i = x; i < row; ++i) {
for (size_t k = y; k < col; ++k) {
if (board[i][k] == true) {
continue;
} else {
if (k + 1 < col && board[i][k + 1] == false) {
board[i][k] = true;
board[i][k + 1] = true;
... 阅读全帖 |
|
f**********t 发帖数: 1001 | 9 // Given an string array sorted by characters in another string.
// Return that sorting base string.
// Example. give you
// {foo, cat, cao, bag, bat, aac}
// return: fcbagto
void buildGraph(vector &vs, unsigned col, unsigned up, unsigned down,
map> &res) {
char pre = '#';
unsigned count = 0;
unsigned uu = up;
for (unsigned i = up; i < down; ++i) {
if (vs[i].size() <= col) {
break;
}
if (vs[i][col] == pre) {
++count;
} else {
... 阅读全帖 |
|
h**d 发帖数: 630 | 10 用preorder的话 不能保证打印col时是从上往下的 比如给5加个right child就看出来了
我的c++代码 用BFS:
void printBT_BFS(TreeNode *root, map > &hash, int &mincol,
int &maxcol)
{
if(root==NULL) return;
queue > q; //store the node pointer and the column
q.push(pair(root, 0));
while(!q.empty())
{
pair item = q.front();
q.pop();
TreeNode *node = item.first;
int col = item.second;
hash[col].push_back(node->... 阅读全帖 |
|
d********i 发帖数: 582 | 11 看到一个答案,可以用一个for loop来检测sudoku 是否valid。
但是dan实在看不懂这句话: board[row / 3 * 3 + i / 3][col / 3 * 3 + i % 3] ==
num
不知道为什么可以check 3 * 3 blocks, 一会除一会乘一会求余,把我看晕。有能帮
忙解释下么?
public static boolean isValidSudoku(char[][] board) {
for (int i = 0; i < board.length; i++) {
for (int j = 0; j < board.length; j++) {
if (board[i][j] != '.') {
if (!isValid(board, board[i][j], i, j)) {
return false;
}
... 阅读全帖 |
|
H********7 发帖数: 2369 | 12 Just last Monday, when Nicolas Sarkozy urged Hillary Clinton to get the U.S.
behind an international intervention in Libya, she demurred. The U.S.
Secretary of State warned the French president that a war could be risky and
bloody, say officials from both countries who were briefed on the exchange.
Yet by the weekend, France, the U.S. and an international coalition stood
poised to take 'all necessary measures' -- code for military strikes -- in
Libya, under United Nations authority.
In hindsight... 阅读全帖 |
|
d**y 发帖数: 18174 | 13 嗯,学习了。美国的小山都排前面去了。跟美帝的奥运会奖牌排名有一拼哪。
珠穆朗玛峰为什么可以例外?如果不跟海平面比,是多少名?
By convention, the prominence of Mount Everest, the Earth's highest mountain
, is taken to equal the elevation of its summit above sea level. Apart from
this special case, there are several equivalent definitions:
The prominence of a peak is the height of the peak’s summit above the
lowest contour line encircling it and no higher summit.
If the peak's prominence is P metres, to get from the summit to any higher
terrain one must desce... 阅读全帖 |
|
w****w 发帖数: 521 | 14 Something like:
with friend_cte as (
select col1 as col from friend where col2='a'
union
select col2 as col from friend where col1='a'
union
select col1 as col from friend join friend_cte
on friend.col2=friend_cte.col
union
select col2 as col from friend join friend_cte
on friend.col1=friend_cte.col
);
select col from friend_cte; |
|
N***m 发帖数: 4460 | 15 来自主题: Programming版 - 编程题一道 看到c/c++笔试问题一道,估计是经典问题了。
=======================================
编程输出以下格式的数据。(趣味题)
a) When i=0
1
b) When i=1
7 8 9
6 1 2
5 4 3
c) When i=2
21 22 23 24 25
20 7 8 9 10
19 6 1 2 11
18 5 4 3 12
17 16 15 14 13
=============================
我用java写了一段程序,试了前几个i=1,2,3,4,能工作,但是感觉写的很罗嗦。
有没有更好的Idea?
======================
附:我的臃肿的java code.
[Main.java]
public class Main {
public stat... 阅读全帖 |
|
t*****w 发帖数: 254 | 16 When I had my job interview, they always tested my SAS skill.However I use R
all the time. To help your preparation, read my R codes to see how much you
can understand it.
%in%
?keyword
a<-matrix(0,nrow=3,ncol=3,byrow=T)
a1 <- a1/(t(a1)%*%spooled%*%a1)^.5 #standadization in discrim
a1<- a>=2; a[a1]
abline(h = -1:5, v = -2:3, col = "lightgray", lty=3)
abline(h=0, v=0, col = "gray60")
abs(r2[i])>r0
aggregate(iris[,1:4], list(iris$Species), mean)
AND: &; OR: |; NOT: !
anova(lm(data1[,3]~data1[,1... 阅读全帖 |
|
i**********e 发帖数: 1145 | 17 比较简单的解法是用一个二维矩阵,然后用 spiral 的方法把矩阵填满,最后一行一行
打印出来。
以下的解法不必要额外空间,给行数和列数就可以马上返回矩阵里的值。
int getVal(int row, int col, int n) {
if (row <= col) {
int k = min(row, n-1-col);
int start = 1 + 4*k*(n- k);
return start + (row - k) + (col - k);
} else {
int k = min(n-1-row, col);
int start = 1 + (n-1)*(2+4*k) - 4*k*k;
return start + (n-1-row-k) + (n-1-col-k);
}
}
void printMatrix(int n) {
for (int r = 0; r < n; r++) {
for (int c = 0; c < n; c++) {
cout << getVal(r, c,... 阅读全帖 |
|
i**********e 发帖数: 1145 | 18 我写的代码如下。
这样打印出来的所有路线还真不是一般的多,
我在想题目的原意是不是指只要路线有相交就不允许?
例如:
1->9->7->3 就不允许,因为 7->3 与 1->9 相交。
如果有以上的条件的话,用 visited cells 就不能解决了。
似乎比较复杂。
#include
#include
using namespace std;
int crossPoint[10][10] = {
{0},
{0, 0, 0, 2, 0, 0, 0, 4, 0, 5},
{0, 0, 0, 0, 0, 0, 0, 0, 5, 0},
{0, 2, 0, 0, 0, 0, 0, 5, 0, 6},
{0, 0, 0, 0, 0, 0, 5, 0, 0, 0},
{0},
{0, 0, 0, 0, 5, 0, 0, 0, 0, 0},
{0, 4, 0, 5, 0, 0, 0, 0, 0, 8},
{0, 0, 5, 0, 0, 0, 0, 0, 0, 0},
{0, 5, 0, 6, 0, 0, 0, 8... 阅读全帖 |
|
i**********e 发帖数: 1145 | 19 这题作为面试题应该考察的就是基础 DFS 和 coding skills,如果要智能的话在面试那么短的时间内是写不出来的。
这题思路不难的,只是 coding 方面要注意,不要出错就行。基本思路就是先实现 isValid() 函数,检测这个 board 是否valid。然后,找出第一个空格内填 1-9,如果 isValid() 的话继续 DFS,直到没有空格为止(那就是找到答案了)。要注意函数返回之前把空格还原。
这个函数:
private boolean pass(int[][] matrix)
里面用了一些重复的代码,可以 refactor 成更简洁些,也可以减少错误发生的机率:
private boolean passHelper(int [][] matrix, int startRow, int startCol, int
endRow, int endCol)
这样你在 pass 函数里只要传叫 passHelper() 三次即可。
1)startRow = 0, startCol = col, endRow = 8, endCol = col { for col = 0... 阅读全帖 |
|
m****t 发帖数: 555 | 20 我的程序运行结果是正确的。
这个c程序输出就是 pylhssrtnaatareyeopsfefasmeietawodny
#include
#include
#include
int main()
{
char *A="paypalisthefastersaferwaytosendmoney";
char B[4][10]={};
int ROW = 4;
int COL;
int N;
COL = strlen(A)/ROW;
if (strlen(A)%ROW) {
COL++;
}
N= strlen(A);
int pos=0;
int c, xb=0;
int x, y;
for (c=0; c<= ROW+COL-2; c++) {
x = xb;
y = c-x;
while (x >= 0 && y <= COL-1 && pos
B[x][y] = A[pos];
pos++;
x--;
y++;
}
if (xb < ROW... 阅读全帖 |
|
s*******f 发帖数: 1114 | 21 //码遍本版
//need more boundary check and a wrapper function for interview.
namespace maze{
struct Info{
int idx;
};
int di[4][2] = {{1, 0}, {0, 1}, {-1, 0}, {0, -1}};
bool InRange(int row, int col, int xx, int yy){
return 0 <= xx && xx < row && 0 <= yy && yy < col;
}
template
void MazeRoute(int m[][col], int row, int x0, int y0, int x1, int y1){
//static Info *info = new Info[row * col];
static vector > path;
... 阅读全帖 |
|
p*****p 发帖数: 379 | 22 刚写了个,上个部分代码
private enum Direction {LEFT, RIGHT, UP, DOWN};
private static float getCurrentPathMax(int currentRow, int currentCol, int[]
[] maze, int[][] visited, Direction lastStep) {
int rows = maze.length, cols = maze[0].length;
if (currentRow < 0 || currentRow >= rows || currentCol < 0 || currentCol
>= cols) {
return -1;
}
if (maze[currentRow][currentCol] == 0) {
// blank
if (visited[currentRow][currentCol] == 3) {
return 0;
... 阅读全帖 |
|
d********o 发帖数: 23 | 23 int pos=i*col+j;
q.offer((px+1)*col+py);
q.offer((px-1)*col+py);
q.offer(px*col+py+1);
q.offer(px*col+py-1);
}
会越界的
这种编码需要col + 1, row + 1 |
|
k**********d 发帖数: 89 | 24 从一个table做select,条件选
当Col A的值为X1,Col B的值为Y1
或者当Col A的值为X2,Col B的值为Y2
或者当Col A的值为X3,Col B的值为Y3
。。。
这样SQL query应该怎么写?
谢谢。。。 |
|
h******t 发帖数: 10 | 25 我刚刚开始自学R,作图的时候遇到了一些问题。可能很基本,但是搜索了半天也没有找
到答案。这里高手多,请大家帮我看看。
我需要做一个 scatterplot 的matrix,找到了 asbio package。 我是这么做的:
data <-read.csv (file.choose(), header=TRUE, sep=",")
library(asbio)
attach(data)
panel.cor.res(x, y, digits = 2, meth = "spearman", cex.cor=1)
panel.lm(x, y, col =1, bg = NA, pch = 16, cex = 1,
col.line = 2, lty = 1)
pairs(data, cex.labels=1, cex=.95, gap=.1, lower.panel=panel.cor.res, upper.
panel=panel.lm)
panel.cor.res 和 panel.lm 是asbio 里的function,可是每次总是出错:
> panel.cor.res(x, y, d... 阅读全帖 |
|
w********2 发帖数: 632 | 26 F-86 in Korea
Last revised October 30, 1999
On June 25, 1950, the forces of North Korea invaded the South. The South
Korean army was poorly organized and badly led, and the initial North Korean
advance was quite rapid. The United Nations Security Council immediately
met in emergency session and ordered the North Koreans to cease their
invasion and withdraw from the South, but these demands were ignored. On
June 27, President Harry Truman authorized American forces to oppose the
invasion, and Gen... 阅读全帖 |
|
发帖数: 1 | 27 Naval History and Heritage Command
Naval History and Heritage Command
Open for Print Social Media
Search
Home
Research
Our Collections
Visit Our Museums
Browse by Topic
News & Events
Get Involved
About Us
DANFS » S » South Dakota I (Armored Cruiser No. 9)
Tags
Related Content
Topic
Document Type
Ship History
Wars & Conflicts
nhhc-wars-conflicts:world-war-i
Navy Communities
File Formats
Image (gif, jpg, tiff)
Location of Archival Materials
South Dakota I (Armored Cruiser No. 9)
1902... 阅读全帖 |
|
发帖数: 1 | 28 防止疮党报复。
National Security Council official Lt. Col. Alexander Vindman and his family
are reportedly ready to move to a military base if the Army determines they
are in “physical danger” following Vindman’s public impeachment hearing
testimony.
Lt. Col. Vindman has already given explosive closed-door testimony about the
now-infamous phone call between President Donald Trump and Ukrainian
President Volodymyr Zelensky that led to the current impeachment inquiry.
But in a sobering development, the A... 阅读全帖 |
|
s*********3 发帖数: 389 | 29 I wrote some Java code afterwards. It seems not very clean. Please comment.
import java.util.*;
//Assumptions:
//1. We can move either up or down or left or right at any point in time,
but not diagonally.
//2. One item in the matrix can not be used twice to compose of the pattern
string.
//3. If different routes lead to the same indexes of matrix items to compose
of the pattern string, display them.
//4. The maximum number of movable steps is (matrix.length - 1) + (matrix[0]
.length - 1) = matri... 阅读全帖 |
|
a********n 发帖数: 1287 | 30 #include
using namespace std;
// 0 means right, 1 means down
void AllPath(int N, int row, int col, int path[], int idx) {
if(row==N-1 && col==N-1) {
for(int i=0; i<2*N-2; i++) {
cout << path[i] << " ";
}
cout << endl;
}
// go down
if(row != N-1) {
path[idx] = 1;
AllPath(N, row+1, col, path, idx+1);
}
// go right
if(col != N-1) {
path[idx] = 0;
AllPath(N, row, col+1, path, idx+1);
}
}
in... 阅读全帖 |
|
S**I 发帖数: 15689 | 31 ☆─────────────────────────────────────☆
peking2 (myfacebook) 于 (Tue Jan 17 13:45:24 2012, 美东) 提到:
稍微扩展了一下。
Boggle game。从一个字符开始找邻居字符然后继续找,形成一个word。条件是,形成
了word之后要继续找,因为可能有更长的word。一旦用了一个字符以后,就不可以重复
使用了。
返回可以找到最多word情况的所有word。
更新一下:可以同时从不同的位置开始找,不一定只从一个字符开始。
☆─────────────────────────────────────☆
autumnworm (虫子,秋天的) 于 (Tue Jan 17 13:46:32 2012, 美东) 提到:
看起来好像是基本的背包问题吧。
☆─────────────────────────────────────☆
mark (花生,微爷远爷的爸爸) 于 (Tue Jan 17 14:08:07 2012, 美东) 提到:
☆───────────────────... 阅读全帖 |
|
f*********m 发帖数: 726 | 32 问题:
N-Queens II
Follow up for N-Queens problem.
Now, instead outputting board configurations, return the total number of
distinct solutions.
我写了个版本,不是很有信心,请大家指正。
int GRID_SIZE = 8;
vector columns(GRID_SIZE,0);
int N_Queens(int row, vector columns){
if (row == GRID_SIZE)
return 1;
else {
int ways = 0;
for (int col = 0; col < GRID_SIZE; col++){
if (checkValid(columns, row, col){
columns[row] = col;
ways += N_Quee... 阅读全帖 |
|
Y**3 发帖数: 21 | 33 void BackTrack(vector > &board,int k,bool& bFindOne)
{
if(k>=81)
{
bFindOne=true;//find a solution
return;
}
int row=k/9;
int col=k%9;
if(isdigit(board[row][col]))//already set
BackTrack(board,k+1,bFindOne);
else
{
for(int i=1;i<=9;i++)
{
board[row][col]=i+'0';
if(isValid(board,row,col))
BackTrack(boar... 阅读全帖 |
|
j*********6 发帖数: 407 | 34 求大牛讲解一下 第四题 substring range 的解法
再贴一个 第四题 第二问 哈利波特 的 2D dp 解法 求大神看看 有什么问题
public static int smallestStrengthValue(int[][] grid){
if( grid == null || grid.length == 0 ||
grid[0] == null || grid[0].length == 0){
throw new IllegalArgumentException("State of grid is illegal!");
}
int row = grid.length;
int col = grid[0].length;
int[][] max = new int[row][col];
for(int i = 0; i < row; i++){
for(int j =... 阅读全帖 |
|
c*******y 发帖数: 98 | 35 我没有明白楼上大牛们的思路,我画了个表
0 1 0 1 0 1 0 1
1 2 3 4 5 6 7 8
0 3 0 7 0 11 0 15
1 4 7 14 21 32 43 58
初始化第一行0 1 0 1 ...
第一列0 1 0 1...
递推公式f(row, col) = f(row-1, col-1) + f(row-1, col) + f(row, col-1)
中间遇到(row+1)*(col+1)为奇数的,设为0。
不知道对不对。 |
|
c*******y 发帖数: 98 | 36 我没有明白楼上大牛们的思路,我画了个表
0 1 0 1 0 1 0 1
1 2 3 4 5 6 7 8
0 3 0 7 0 11 0 15
1 4 7 14 21 32 43 58
初始化第一行0 1 0 1 ...
第一列0 1 0 1...
递推公式f(row, col) = f(row-1, col-1) + f(row-1, col) + f(row, col-1)
中间遇到(row+1)*(col+1)为奇数的,设为0。
不知道对不对。 |
|
c*******y 发帖数: 98 | 37 我没有明白楼上大牛们的思路,我画了个表
0 1 0 1 0 1 0 1
1 2 3 4 5 6 7 8
0 3 0 7 0 11 0 15
1 4 7 14 21 32 43 58
初始化第一行0 1 0 1 ...
第一列0 1 0 1...
递推公式f(row, col) = f(row-1, col-1) + f(row-1, col) + f(row, col-1)
中间遇到(row+1)*(col+1)为奇数的,设为0。
不知道对不对。 |
|
c*******y 发帖数: 98 | 38 我没有明白楼上大牛们的思路,我画了个表
0 1 0 1 0 1 0 1
1 2 3 4 5 6 7 8
0 3 0 7 0 11 0 15
1 4 7 14 21 32 43 58
初始化第一行0 1 0 1 ...
第一列0 1 0 1...
递推公式f(row, col) = f(row-1, col-1) + f(row-1, col) + f(row, col-1)
中间遇到(row+1)*(col+1)为奇数的,设为0。
不知道对不对。 |
|
c*******y 发帖数: 98 | 39 我没有明白楼上大牛们的思路,我画了个表
0 1 0 1 0 1 0 1
1 2 3 4 5 6 7 8
0 3 0 7 0 11 0 15
1 4 7 14 21 32 43 58
初始化第一行0 1 0 1 ...
第一列0 1 0 1...
递推公式f(row, col) = f(row-1, col-1) + f(row-1, col) + f(row, col-1)
中间遇到(row+1)*(col+1)为奇数的,设为0。
不知道对不对。 |
|
c*******y 发帖数: 98 | 40 我没有明白楼上大牛们的思路,我画了个表
0 1 0 1 0 1 0 1
1 2 3 4 5 6 7 8
0 3 0 7 0 11 0 15
1 4 7 14 21 32 43 58
初始化第一行0 1 0 1 ...
第一列0 1 0 1...
递推公式f(row, col) = f(row-1, col-1) + f(row-1, col) + f(row, col-1)
中间遇到(row+1)*(col+1)为奇数的,设为0。
不知道对不对。 |
|
v***o 发帖数: 287 | 41 来自主题: JobHunting版 - 电面题一个 void diagonalOrder(int matrix[ROW][COL])
{
// There will be ROW+COL-1 lines in the output
for (int line=1; line<=(ROW + COL -1); line++)
{
/* Get column index of the first element in this line of output.
The index is 0 for first ROW lines and line - ROW for remaining
lines */
int start_col = max(0, line-ROW);
/* Get count of elements in this line. The count of elements is
equal to minimum of line number, COL-start_col and ROW... 阅读全帖 |
|
v***o 发帖数: 287 | 42 来自主题: JobHunting版 - 电面题一个 void diagonalOrder(int matrix[ROW][COL])
{
// There will be ROW+COL-1 lines in the output
for (int line=1; line<=(ROW + COL -1); line++)
{
/* Get column index of the first element in this line of output.
The index is 0 for first ROW lines and line - ROW for remaining
lines */
int start_col = max(0, line-ROW);
/* Get count of elements in this line. The count of elements is
equal to minimum of line number, COL-start_col and ROW... 阅读全帖 |
|
i*******a 发帖数: 61 | 43 1 best time to sell and buy stock1
2 find k largest/smallest in n sorted list
3 lru cache
4 design etsy database schema
5 find element in rotated array
~~~~~~~~~~~~~~~~~~~~~~
都不难,可惜挂了,自己分析,可能是1 第四轮印度小哥说的优化用db polymorphism
没懂(真的不太懂这个)2自己写题慢了(可是聊天20分钟,面试官也没有要出下一题
的意思)
~~~~~~
dropbox的在线题目
就是一个矩阵,来表示n个人之间的关系,可以是朋友(用f)或者是敌人(e), 俄且
这个关系是双向的,现在 给你一个string的关系,还有两个人的id判断这个string的
关系是合法还是非法的,string关系比如 feffeef 是可以倒回来的。
~~~~~~~~~~
马上要面L家了,想请教一下几道经典题,new grad小白,啥都不懂,请各位大牛不吝
赐教:
1library design题,design一个java... 阅读全帖 |
|
R*********4 发帖数: 293 | 44 A[i++] A[++i++]
这些东西,只有谭浩强的测试题才用。而且懂这个东西一点意义都没有。为了条例清楚
,你尽量避免用这个东西,特别是在面试中。
主要没看到你的题目,我不好评论。
似乎我的感觉是,考试题目,是想要你用 二分法(B search)。但是你用了线性。
这个似乎是差了几个数量级。
比如一个array是事先排好序的。加入有一百万个,用B search找到想要的东西,次数
一般不会超过50次。你线性下去i++,那不知道有多少次了。
这是一小段测试程序:假设都是10000次
time_t start, finish;
int num = 0;
list col;
start = clock();
for(int i=0;i<10000;++i){
col.push_back(i);
num += col.size();
}
finish = clock();
cout<
col.clear();
start = c... 阅读全帖 |
|
m********0 发帖数: 2717 | 45 The thing is the it's not a graph for any stock. I just make it with the
following R code,
require(TTR)
ret<-cumsum(rnorm(252,sd=0.036))
ret2<-exp(ret)
p<-50*ret2
ma20<-SMA(p,20)
ema20<-emaTA(p,20)
ema50<-emaTA(p,50)
plot(p, type="l")
lines(ema20, type="l",col='green')
lines(ema50, type="l",col='red')
and I used lognormal distribution for the returns, textbook assumptions
for
a big group of models.
skeptic(as exists everywhere), yes, I borrowed this idea from ET. Please
don
't rush to criticize,... 阅读全帖 |
|
C*****e 发帖数: 367 | 46 海德堡要理问答主日18
来自CCWiki中国基督徒百科(Godwithus神同在网)
目录
1 英文版
2 英文2011版
3 赵中辉版
4 陈达/王志勇版
5 基督教要义圣经课程版
6 链接参考
英文版
18. Lord's Day
Q. 46.
How dost thou understand these words, "he ascended into heaven"?
A.
That Christ, in sight of his disciples, was taken up from earth into heaven;
(a)
and that he continues there for our interest, (b)
until he comes again to judge the quick and the dead. (c)
(a) Acts 1:9; Matt.26:64; Mark 16:19; Luke 24:51. (b) Heb.7:25;
Heb.4:14; Heb.9:24; Rom.8:34; Eph.4:10; Col.3:1. (c) A... 阅读全帖 |
|
I****J 发帖数: 516 | 47 Wall Street Journal ASIA NEWS JULY 27, 2011, 12:09 P.M. ET
China Says Aircraft Carrier Only for Research, Training
BEIJING—China's Defense Ministry said its first aircraft carrier would be
used for "research, experiments and training" and would not affect its
defensive naval strategy, in an apparent attempt to ease regional concerns
that the vessel could be used to enforce Chinese territorial claims.
Senior Col. Geng Yansheng, a Defense Ministry spokesman, also confirmed for
the first time that ... 阅读全帖 |
|
k******y 发帖数: 1407 | 48 我试着compile一个大的MPI程序,先前已经安装了OpenMPI,调试小的MPI的test程序可以
但是现在调试:mpif90 -O3 xxx.f
[lots of outputs]
ZnSimA4.f(434): (col. 8) remark: LOOP WAS VECTORIZED.
ZnSimA4.f(436): (col. 8) remark: LOOP WAS VECTORIZED.
ZnSimA4.f(437): (col. 8) remark: LOOP WAS VECTORIZED.
ZnSimA4.f(442): (col. 14) remark: LOOP WAS VECTORIZED.
ZnSimA4.f(489): (col. 14) remark: LOOP WAS VECTORIZED.
ld: in /opt/intel/fce/10.1.017/lib/libimf.a(cbrt_gen.o),
ObjectFileAddressSpace::mappedAddress(0xFFFFFFFFFFFFFFFC) not in any section |
|
B*****g 发帖数: 34098 | 49 不明白你说的。题目说"OR operator displays a record if ANY conditions listed
are true"。除了CASE那个其他肯定符合题目要求。用1/0=0就是简化题目,也可
以改成col1/(col1-col2)<1等。赫赫,自己测试一下吧。其实我还是很厚到
的,还没改成1=1 OR col1='A'(col1是number)。 |
|
b*****e 发帖数: 223 | 50 左边那个,用 plot,大概是
read.csv ("path", header=T)
pdf(file='c:/temp/leftplot.pdf')
plot (x, y, lty=2, pch=22 col='red', main="My Plot Title", xlab="My x axis label", ylab='My y axis label')
dev.off ()
右边那个,用 plot 加 lines
read.csv ("path", header=T)
pdf(file='c:/temp/rightplot.pdf')
plot (x, y, lty=2, pch=22 col='red', main="My Plot Title", xlab="My x axis label", ylab='My y axis label') - 用第一条线的 x,y 画
lines (x, y, lty=3, pch=23, col='blue') - 用第二条线的 x,y 画
lines (x, y, lty=4, pch=24, col='purple... 阅读全帖 |
|