"BZOJ1011" "HNOI2008" the distant planets are fuzzy DP based on the allowable error

Source: Internet
Author: User

Exercises

Violence must not be over,

But we can blur the divisor, let a part of the number of unity with a divisor, so that can be within the 5% error quickly out of the solution.

Amount, but the previous large section of the movement of the value of the need for violence, or it is difficult to meet 5%.


To a god blog Http://hi.baidu.com/zeonsgtr/item/789da6f2838a3dc742c36ab7

And put a code on it.

#include <cmath> #include <cstdio> #include <cstring> #include <algorithm> #define N 101000# Define EPS 1e-7#define LL long Long using namespace std;int N; LL M[n],sum[n];d ouble a,f[n];int Main () {//freopen ("test.in", "R", stdin); scanf ("%d%lf", &n,&a); for (int i=1;i <=n;i++) scanf ("%lld", &m[i]), sum[i]=sum[i-1]+m[i];for (int i=min (n,2000); i>=1;i--)//violence seeks out the front F-value {int k= (int ) (a*i); if (Fabs (double) (k+1)/a-i) <eps (int k++;for) j=1;j<=k;j++ (double) (f[i]=f[i]+m[i]*m[j]/);} for (int i=2001;i<=n;i++)//Because the topic allows for small errors, we can approximate some of the divisor. {int k= (int) (a*i), mid= (1+k) >>1; f[i]=sum[k]*m[i]/(Double) (i-mid);} for (int i=1;i<=n;i++) printf ("%lf\n", F[i]); return 0;}



"BZOJ1011" "HNOI2008" the distant planets are fuzzy DP based on the allowable error

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.