Advertisement
Guest User

Untitled

a guest
Feb 21st, 2019
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.53 KB | None | 0 0
  1. #include<stdio.h>
  2. #include<math.h>
  3.  
  4. int main()
  5. {
  6.     int z;
  7.     double s;
  8.     scanf("%d",&z);
  9.     while(z--){
  10.         int x,k,c;
  11.         scanf("%d%d",&x,&k);
  12.         double lx,px,cs,fs;
  13.         lx=0;
  14.         px=x/2;
  15.        
  16.        
  17.        
  18.         while(px-lx>pow(0.1,k)){
  19.         s=(lx+px)/2;
  20.         if(s*s<x){
  21.             lx=s;
  22.         }else{
  23.             px=s;}
  24.  
  25. }  
  26. cs = (int) ceil(s);         fs = (int) floor(s);
  27. if (cs*cs > x)  printf("%d ", fs);
  28. else printf("%d ", cs);
  29.  
  30.         printf("%.15LF ", s);
  31.  
  32.         if (fs*fs < x) printf("%d\n", cs);
  33.  
  34.         else printf("%d\n", fs);
  35. }  
  36. return 0;  
  37. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement