Exercises
I don't know why I use this, but it does.
Well, the V here has a monotonous relationship with the result, so you can get a two-point solution ...
Shallow comprehension of Lagrange equation (possibly wrong):
Set a λ to two points and use this value to calculate the derived variable, and then check whether the limit is met
So get the correct argument and then the solution.
The equation is Ⅰ, while the formula Ⅱ is the V-variable biasing function of the equation, and Ⅲ is a small deformation.
(Image from Http://txhwind.blog.163.com/blog/static/203524179201313112815690/)
Code:
#include <cstdio> #include <cstring> #include <iostream> #include <algorithm> #define N 10100# Define EPS 1e-9#define inf 1e9using namespace std;int n;double k[n],v1[n],v[n],s[n];void calc (double lambda)//based on this λ to calculate the speed, { for (int i=0;i<n;++i) {double L=max (0.0,v1[i]), r=1e9;for (int c=0;c<130;++c) {double mid= (l+r) *0.5; ((2.0*lambda* k[i]*mid*mid* (Mid-v1[i]) <1.0) l:r) =mid;} V[i]=l;}} int main () {//freopen ("test.in", "R", stdin), int i,j,k;double e;scanf ("%d%lf", &n,&e); for (I=0;i<n;++i) scanf ("%lf%lf%lf", S+i,k+i,v1+i);d ouble l=0,r=1e9;for (k=90;k--;) {double mid= (l+r) *0.5,sum=0;calc (mid), and//based on this λ to calculate the speed, for (I=0;i<n;++i) sum+=k[i]* (V[i]-v1[i]) * (V[i]-v1[i]) *s[i]; You can then know whether the speed is consistent, (sum<e?r:l) =mid;} Double Ans=0;for (i=0;i<n;++i) ans+=s[i]/v[i]; Now V is a set of compliant V, printf ("%lf\n", ans); return 0;}
"BZOJ2876" "NOI2012" Riding Sichuan-Tibet Lagrange Multiplier,