题意

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. unity中实现三个Logo图片进行若隐若现的切换并有延时切换图片的效果

    public GameObject canvas; private Transform logoParent; private Transform Logo_logo; //logo一 private ...

  2. bzoj3277

    题解: 后缀自动机 然后抄了一发题解 可以看看这个博客:http://blog.csdn.net/clover_hxy/article/details/53861268 代码: #include< ...

  3. Mysql 数据库意向锁意义

    锁:对 “某种范围” 的数据上 “某种锁”1.“某种范围”:行.表 2.“某种锁”2.1 共享锁Shared Locks(S锁)1.兼容性:加了S锁的记录,允许其他事务再加S锁,不允许其他事务再加X锁 ...

  4. JavaScript -基础- 函数与对象(三)正则、Match对象

    一.正则对象 1.创建方法 1)方式一 var re_obj=new RegExp("\d+","g") 规则+模式(g 全局模式/i 不区分大小写/gi) r ...

  5. ES6-循环

    forEach 方法来遍历数组,不能使用break语句中断循环,也不能使用return语句返回到外层函数 myArray.forEach(function (value) { console.log( ...

  6. Remove duplicates from array

    //Given a sorted array, remove the duplicates in place such that each element appear only // once an ...

  7. 线程安全的集合类、CopyOnWrite机制介绍(转)

    看过并发编程的书,这两种机制都有所了解,但不扎实其实.看到别人的博客描述的很精辟,于是转过来,感谢! 原文链接:https://blog.csdn.net/yen_csdn/article/detai ...

  8. PropertiesUtil 读取properties

    package com.midea.clean.util; import java.io.InputStream; import java.io.UnsupportedEncodingExceptio ...

  9. 2018ICPC青岛 E - Plants vs. Zombies (二分+模拟)

    ZOJ - 4062 题意:有n个植物排成一排,按顺序植物的编号是1-n,每个植物都有一个生长速率,有一个机器人,机器人可以走m步,每走一步,这个机器人就会浇一次水,浇一次水那个植物就会长 自身的生长 ...

  10. nginx——优化 Nginx worker 进程数

    Nginx 有 Master 和 worker 两种进程,Master 进程用于管理 worker 进程,worker 进程用于 Nginx 服务 worker 进程数应该设置为等于 CPU 的核数, ...