r****y 发帖数: 1437 | 1 Friend asked me this question and I have no clue how to do it
A set of numbers, sqrt(1), sqrt(2), ..., sqrt(50)
You divide these 50 numbers into two group, the sum of the
first group is sum1, the sum of the second group is sum2, let
dsum = abs(sum1 - sum2)
question, how you divide these 50 numbers to make dsum as small as
possible?
The gut is dsum could be very small, -> 0. But no idea how to prove
and how to find those two sets. Hehe.
|
|
p*********g 发帖数: 26 | 2 请问两个器材的距离定义?假设为|x0-x1|+|y0-y1|
1. 两个array,cntn[n], cntm[m], 把所有e个器材过一遍,之后cntn[i]记录所有在
col[i]的器材个数,cntm类似,O(e)。在此两个数组上计算lsum, lsum[i]为所有横坐
标<=i的器材个数,类似的再计算rsum, upsum和downsum.O(n+m)
2. 取第一个没有器材的点,比如m[i][j],计算从该点到所有e个器材的距离之和 - O(
e)
3. 然后遍历所有没有器材的点,从左向右从上到下;向右遍历时之前的距离和dsum减去
所有位于右侧的器材个数(rsum[i] - cntn[i])*1,加上左侧和当前列的器材个数(lsum
[i])*1;由上至下类似。O(n*m)
返回#3中最小值。
各位大神走过路过还请轻拍 |
|
w**k 发帖数: 6722 | 3 这里都是ETF
发包子吧
AADR AAIT AAXJ ACIM ACWI ACWV ACWX ADRA ADRD ADRE ADRU
ADZ AFK AGA AGF AGG AGLS AGND AGOL AGQ AGZ AGZD AIA
AIRR ALD ALFA ALTS AMJ AMLP AMPS AMU AMZA AND ANGL
AOA AOK AOM AOR ARGT ARKG ARKK ARKQ ARKW ASEA ASHR
ASHS AUNZ AUSE AXJL AXJS AXJV AYT AZIA BAB BABS BAL
BAR BBC BBH BBRC BCHP BCM BDCL BDCS BDD BFOR BIB BICK
BIK BIL BIS BIV BIZD BJK B... 阅读全帖 |
|
t*****n 发帖数: 4908 | 4 照楼主的测试例子我用dgemv()和dsum()改写了一下。没有减少循环层次。另外用
gotoblas做blas库。在我的athlon双核机器上速度是gcc -03两倍。
那位在linux上跑一下看看。多谢
#include
#include
#include
#include
#define size 2000
int main(void)
{
double *m;
double x[size], k[size];
long begin, end;
double sum = 0.0;
int i, j;
begin = time(0);
m = malloc(size * size * sizeof(*m));
for (i = 0; i < size; i++)
{
for (j = 0; j < size; j++)
{
m[i * size + j] = i + j;
... 阅读全帖 |
|