锐单电子商城 , 一站式电子元器件采购平台!
  • 电话:400-990-0325

备战省赛4 问题 E: LED;

时间:2023-07-13 23:37:01 二极管vj

备战省赛4 问题 E: LED;

添加链接描述
感觉题意为 求一个使 分段函数合法 最小误差值(由最大值和最小值确定,所以二分,感觉他给的值有问题把 两个 109 109,所以暴力刚刚开始提示re 素组开小 了 所以不是109的感觉,emmmmmmmmm 二分最小误差值 然后验证。
A Light-Emitting Diode (LED) is a semiconductor light source, which emits light when an electric current of voltage higher than a threshhold is applied to its leads. ACM R&D recently reported that they have succesfully developed a new LED, namely, ACMOLED. An ACMOLED has a special behavior that the intensity of light emitted from it changes in two steps as the voltage of the electric current increases, as depicted in the graph below.

As shown, an ACMOLED is not activated in the voltage range from 0 to V1, while it emits light with intensity L1 ≥ 0 when the voltage reaches the first threshold V1 and light with intensity L2 ≥ L1 when the voltage reaches the x threshold V2. More specifically, if F(v) is the function that maps voltage v to the intensity of light emitted from an ACMOLED, then for four real numbers L1, L2, V1, and V2 with 0 ≤ L1 ≤ L2 and 0 < V1 < V2, we have

The very issue now is that ACM R&D still does not know the exact values of two threshold voltage values V1 and V2 and the two intensity values L1 and L2 as well. Researchers in ACM R&D plan to estimate these four values for ACMOLEDs by repeated experiments.
Experiments are performed by applying current of a specific voltage and observing the intensity of light emitted from an ACMOLED. After n repeated experiments with different voltage values, obtained are the data of n tuples (v1, l1), (v2, l2), …, (vn, ln), where li is the observed intensity for voltage vi. Due to the impreciseness of the observing device and other reasons, the experimental data are not accurate and may contain some error. Nonetheless, they want to find a best estimated intensity function F(v) that minimizes the following error function:

where |x| denotes the absolute value of a real number x.
For a given data of n tuples, write a program that finds an estimated intensity function F that minimizes the above error function and outputs the value of error(F).

输入

Your program is to read from standard input. The input starts with a line containing an integer n (1 ≤ n ≤ 300,000), where n is the number of tuples (vi, li) in the experimental data. In the following n lines, each line contains two integers, which range inclusively from 0 to 109, representing vi and li in each tuple (vi, li) of the experimental data. Note that you may assume that there are no two tuples (vi, li) and (vj, lj) in the input such that 1 ≤ i < j ≤ n and vi = vj.

输出

Your program is to write to standard output. Print exactly one line consisting of one real number, rounded to the first decimal place, which represents the minimum value of error(F).

样例输入
复制样例数据 5
0 0
2 1
3 5
6 7
7 11

样例输出
1.0

发光二极管(LED)当电压高于阈值的电流施加到其引线上时,它是半导体光源。ACM研发部最近报告说,他们成功开发了一种新的LED,即Acmoled。Acmoled有一种特殊的行为,即当电流电压升高时,从它发出的光强分两步变化,如下图所示。

如图所示,0到v在1的电压范围内,未激活Acmoled,当电压达到第一阈值时v1.它发出强度l1≥当电压达到x阈值时v2时,它发出强度l2≥l1的光。更具体地说,如果f(v)它是将电压v映射到无钼酸盐发出的光强度的函数,因此对于4个实数l1、l2、v1和v2,0≤l1≤l2和0

现在的问题是,ACM研发人员仍然不知道两个阈值的电压值v1和v以及两个强度值l1和l2的确切值。ACM研究人员计划通过反复实验来估计这四种药物的含量。
实验是通过施加特定电压的电流和观察从无钼酸盐发出的光的强度来完成的。n个元组通过n次不同电压值的重复试验获得(v1,l1),(v2,l2),…,(vn,ln)数据,其中li是电压vi由于观测装置不准确,实验数据不准确,可能存在一定的误差。尽管如此,他们仍然希望找到最好的估计强度函数f(v),以下误差函数最小化:

x表示实数x的绝对值。
编写n个元组的给定数据程序,找到估计强度函数f,最小化上述误差函数,输出误差值(f)。

内幕

您的程序将从标准输入中读取。包括整数的输入n(1≤n≤实验数据中的元组数验数据中的元组数(vi,li)。在以下n行中,每行包含从0到109两个整数,表示实验数据的每个元组(vi,li)中的vi和li。注意,您可以假设输入中没有两个元组(vi,li)和(vj,lj),这样1≤i

特技

您的程序将写入标准输出。只打印一行,由一个实数组成,四舍五入到小数点,表示最小误差值(f)。

附带条件
复制样品数据5
0 0
2 1
3 5
6 7
7 11

附带条件

#include #include using namespace std; typedef long long int ll; ll max(ll a,ll b) {     return a>=b?a:b; } ll min(ll a,ll b) {     return a<=b?a:b; } ll n; struct node{ ll v; ll l; }a[312345]; bool cmd(node x,node y) {     return x.vx)             break;     }     if(i>n)         return 1;     ll Max=0,Min=1e11;     for(;i<=n;  i)     {         Max=max(Max,a[i].l);         Min=min(Min,a[i].l);         if( (Max-Min)/2>x )             break;     }     l1=(Max Min)/2;     if(i>n)         return 1
    Max=0,Min=1e11;
    for(;i<=n;++i)
    {
        Max=max(Max,a[i].l);
        Min=min(Min,a[i].l);
        if( (Max-Min)/2>x )
            break;
        l2=(Max+Min)/2;
    }
    if(i<=n)
        return 0;
    return l2>=l1;
}
int main()
{
    scanf("%lld",&n);
    for(int i=1;i<=n;i++)
    {
        scanf("%lld%lld",&a[i].v,&a[i].l);
        a[i].l=a[i].l*10;
    }
    sort(a,a+1+n,cmd);
    ll base=0,j=0;
    for(int i=1;i<=n;i++)
    {
        if(a[i].v==0)
            base=max(a[i].l,base);
        else
            a[++j]=a[i];
    }
    n=j;
    ll r=1e11,l=0,res=-1;
    while(l<=r)
    {
        ll mid=(l+r)/2;
        if(check(mid))
        {
            res=mid;
            r=mid-1;
        }
        else
        {
            l=mid+1;
        }
    }
    res=max(base,res);
    ll x=res%10;
    res=res/10;
    printf("%lld.%lld\n",res,x);
    return 0;
}

锐单商城拥有海量元器件数据手册IC替代型号,打造电子元器件IC百科大全!

相关文章