Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.*;
- public class prob7{
- public static int p,q,r,s,t,u;
- public static double f(int x){
- return p*Math.exp(-x) + q*Math.sin(x)+r*Math.cos(x)+s*Math.tan(x)+t*x*x+u;
- }
- public static int bi(){
- int low=0;
- int high=1;
- while(low+high>0.0000001){
- int x=(low+high)/2;
- if(f(low)*f(x)<=0){
- high=x;
- }
- else{
- low=x;
- }
- }
- return (low+high)/2;
- }
- public static void main(String args[]){
- Scanner input=new Scanner(System.in);
- int n=input.nextInt();
- while(n>0){
- p=input.nextInt();
- q=input.nextInt();
- r=input.nextInt();
- s=input.nextInt();
- t=input.nextInt();
- u=input.nextInt();
- if(f(0)*f(1)>0){
- System.out.println("Impossivel");
- }
- else{
- double out=bi();
- System.out.printf("%.4lf\n", out);
- }
- n--;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement