题意

PDF

分析

在\(0\le x\le 1\)时,\(f(x)=pe^{-x}+q\sin x+r\cos x+s\tan x+tx^2+u\)是减函数,所以当\(f(0)\ge 0 \wedge f(1)\le 0\)时,函数有唯一零点,否则没有。

那么二分答案即可。控制二分次数,时间复杂度\(O(100)\)

代码

#include<bits/stdc++.h>
#define rg register
#define il inline
#define co const
template<class T>il T read(){
    rg T data=0,w=1;rg char ch=getchar();
    while(!isdigit(ch)) {if(ch=='-') w=-1;ch=getchar();}
    while(isdigit(ch)) data=data*10+ch-'0',ch=getchar();
    return data*w;
}
template<class T>il T read(rg T&x) {return x=read<T>();}
typedef long long ll;

#define F(x) (p*exp(-x)+q*sin(x)+r*cos(x)+s*tan(x)+t*(x)*(x)+u)
co double eps=1e-14;
int main(){
//  freopen(".in","r",stdin),freopen(".out","w",stdout);
    int p,r,q,s,t,u;
    while(~scanf("%d%d%d%d%d%d",&p,&q,&r,&s,&t,&u)){
        if(F(1)>eps||F(0)<-eps) {puts("No solution");continue;}
        double x=0,y=1,m;
        for(int i=0;i<100;++i){
            m=(x+y)/2;
            F(m)<0?y=m:x=m;
        }
        printf("%.4lf\n",m);
    }
    return 0;
}

UVA10341 Solve It的更多相关文章

  1. uva10341 - solve it (二分查找)

    题目:uva10341-solve it 题目大意:求解给定的方程式解题思路:由于这个方程式在给定的x的范围内是单调递减的.所以能够用二分查找来尝试x的值.这里的 x是要求保留4小数,所以当区间缩小到 ...

  2. UVA 10341.Solve It-二分查找

    二分查找 二分查找又称折半查找,优点是比较次数少,查找速度快,平均性能好:其缺点是要求待查表为有序表,且插入删除困难.因此,折半查找方法适用于不经常变动而查找频繁的有序列表.首先,假设表中元素是按升序 ...

  3. .Uva&LA部分题目代码

    1.LA 5694 Adding New Machine 关键词:数据结构,线段树,扫描线(FIFO) #include <algorithm> #include <cstdio&g ...

  4. UVA10341-Solve It-二分查找

    二分查找 二分查找又称折半查找,优点是比较次数少,查找速度快,平均性能好:其缺点是要求待查表为有序表,且插入删除困难.因此,折半查找方法适用于不经常变动而查找频繁的有序列表.首先,假设表中元素是按升序 ...

  5. UVA10341:Solve It(二分+math.h库)

    题目:http://acm.hust.edu.cn/vjudge/contest/view.action?cid=68990#problem/E 题目要求:p*e-x+ q*sin(x) + r*co ...

  6. Solve VS2010 Error "Exceptions has been thrown by the target of an invocation"

    Sometimes when you open a VS2010 project, an error window will pop up with the error message "E ...

  7. solve the problem of 'java web project cannot display verification code'

    my java code of the function: package com.util; import java.awt.Color; import java.awt.Font; import ...

  8. HDU1086You can Solve a Geometry Problem too(判断线段相交)

    You can Solve a Geometry Problem too Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/3 ...

  9. Solve

    /// <summary> /// Solves this instance. /// </summary> /// <returns>IFeatureClass. ...

随机推荐

  1. Oracle 12c的自增列Identity Columns

    在Oracle的12c版本中,Oracle实现了类似MySQL中的auto_increment的自增列,下面我们看一起Oracle是怎么实现的. Oracle Database 12c Enterpr ...

  2. js 设置img标签的src资源无法找到的替代图片(通过img的属性设置)

    在网站的前端页面设计中,要考虑到img图片资源的存在性,如果img的src图片资源不存在或显示不出来,则需要显示默认的图片.如何做到呢? 一.监听document的error事件 document.a ...

  3. Problem A 你会定义类吗?

    Description 定义一个类Demo,有构造函数.析构函数和成员函数show(),其中show()根据样例的格式输出具体属性值.该类只有一个int类型的成员. Input 输入只有一个整数,in ...

  4. day 67 django orm的基础

    django项目 安装: 创建项目 配置(setting,static,csrf) 创建app,python manage.py startapp app1 三部分 urls.py路由配置 1,普通正 ...

  5. ios遮罩层的简单使用

    /** 大图 */ - (IBAction)bigImg { //1.添加按钮遮罩层 UIButton *cover=[[UIButton alloc] init]; cover.frame=self ...

  6. Linux并发执行很简单,这么干就对了

    嗯,就像标题说的那么简单而已 &的并发功能 time for i in `grep server /etc/hosts | awk '{print $1}'`; do (ssh $i &quo ...

  7. 替换Jar包内的文件

    要替换Jar包内的文件可以用以下命令实现: jar uvf myjar.jar com/test/myclass.class 这里值得注意的是  myclass.class 必须放在com/test ...

  8. web前端优化

    在谈到Web优化之前,我们回到一个更原始的问题,Web前端的本质是什么.我的理解是: 将信息快速并友好的展示给用户并能够与用户进行交互.快速的意思就是在尽可能短的时间内完成页面的加载,试想一下当你在淘 ...

  9. Python学习笔记第二十一周

    目录: 1.URL 2.Models - 操作 3.Templates - html模板的使用 - 自定义函数 4.cookie和session 5.分页(自定义分页) 6.Form验证 内容: 1. ...

  10. 【转载】 大龄码农那些事——也谈996.ICU

    原文地址: https://www.cnblogs.com/helloyaren/p/10657414.html 请扫码关注!!! 您的关注将是您做的最正确的事情!!! 大龄码农那些事专注分享大龄码农 ...