UVA-1456 Cellular Network

Source: Internet
Author: User

Main topic:

The positioning of mobile phones in cellular networks is a fundamental problem. Given that cellular networks have learned that mobile phones are in C1, C2,..., cn One of these areas, the simplest way is to simultaneously find mobile phones in these areas. But this is a waste of bandwidth. Since cellular networks can tell the probability of a mobile phone in this different region, a compromise is to divide the areas into W groups and then access them sequentially. For example, if the phone is known to be in 5 regions with probabilities of 0.3, 0.05, 0.1, 0.3, and 0.25,w=2, then one method is to access {C1,C2,C3} at the same time, and then access {C4,C5} at the same time, with the mathematical expectation that the number of accesses to the region is (0.3+0.05+0.1) + (3+2) * (0.3+0.25) = 4.1. Another method is to access {C1,C4} at the same time, and then access {C2,C3,C5}, and the mathematical expectation for the number of access areas is 2x (0.3+0.3) + (3+2) x (0.05+0.1+0.25) = 3.2.

Problem Solving Ideas:

It can be found from the formula that, in order to minimize the total expected value, the area with large probability should be placed in front of the access as far as possible.

So first sort all probabilities from big to small. Then group, you can take a continuous paragraph into a group.

F[I][J]: The first I, the minimum expected value into the J group
F[I][J] = min{F[k-1][j] + i*sum[k~i], 1<=k<=i}

#include <cstdio>#include <iostream>#include <algorithm>using namespace Std;intMain () {intT scanf"%d", &t); while(t--) {intN, W;Double sum[ the] = {0}, dp[ the][ the] = {0}, Total =0; scanf"%d%d", &n, &w); for(inti =1; I <= N; i++) {scanf ("%LF", &sum[i]); Total + =sum[i]; } sort (sum+1,sum+ N +1, greater<Double> ()); for(inti =1; I <= N; i++)sum[I] =sum[i]/total +sum[I1]; for(inti =1; I <= N; i++) {dp[i][0] =0x3f3f3f3f; for(intj =1; J <= W; J + +) {Dp[i][j] =0x3f3f3f3f; for(intK =1; K <= i; k++) Dp[i][j] = min (dp[i][j], dp[k-1][j-1] + I * (sum[I]-sum[k-1])); }} printf ("%.4lf\n", Dp[n][w]); }return 0;}

Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.

UVA-1456 Cellular Network

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.