由买买提看人间百态

topics

全部话题 - 话题: maxv
(共0页)
d*z
发帖数: 150
1

#define MINV -10
#define MAXV 30
double prob[MAXV-MINV+1];
double tprob[MAXV-MINV+1];
int main()
{
int i,j;
prob[10-MINV]=1.0;
for(i=0;i<20;i++){
tprob[0]=prob[0];
for(j=1;j<=MAXV-MINV-1;j++){
tprob[j-1]+=prob[j]/2.0;
tprob[j+1]+=prob[j]/2.0;
}
tprob[MAXV-MINV-1]+=prob[MAXV-MINV]/2.0;
memcpy(prob,tprob,sizeof(tprob));
}
printf("%.13f\n",prob[0]);
}
a****n
发帖数: 1887
2
来自主题: JobHunting版 - 聊聊黑名单吧
假设数组为int sum[N], 需要分为M段
int foo()
{
int maxv = accumulate(&num[0],&num[N],0);
int minv = *max_element(&num[0],&num[N]);
int midv;
while(minv < maxv)
{
midv = (minv + maxv)>>1;
int k = 0;
int sum = 0;
for (int i = 0; i < N; ++i)
{
sum += num[i];
if (sum > midv)
{
sum = num[i];
++k;
}
}
if (k < M) maxv = midv;
else minv = midv + 1;
B*****t
发帖数: 335
3
来自主题: JobHunting版 - What's the algorithm to solve this problem?
代码才是硬道理! 贴个我的code,可能有bug,欢迎指出。另外,DFS没有优化。
#include
#include
using namespace std;
const int N = 10000, MaxTimeValue = 100000;
class Job {
public:
int st, ed, money;
}nd[N];
int n, maxV = 0x80000000;
bool cmp(const Job &a, const Job &b) {
return a.st }
void dfs(int ix, int endTime, int tot) {
if(ix==n) {
if(tot>maxV) maxV = tot;
return;
}
if(nd[ix].st>=endTime) dfs(ix+1, max(nd[ix].ed,
endTime), tot+nd[ix].mone
(共0页)