Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<stdio.h>
- #include<math.h>
- int main()
- {
- int z;
- double s;
- scanf("%d",&z);
- while(z--){
- int x,k,c;
- scanf("%d%d",&x,&k);
- double lx,px,cs,fs;
- lx=0;
- px=x/2;
- while(px-lx>pow(0.1,k)){
- s=(lx+px)/2;
- if(s*s<x){
- lx=s;
- }else{
- px=s;}
- }
- cs = (int) ceil(s); fs = (int) floor(s);
- if (cs*cs > x) printf("%d ", fs);
- else printf("%d ", cs);
- printf("%.15LF ", s);
- if (fs*fs < x) printf("%d\n", cs);
- else printf("%d\n", fs);
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement