Medium Search Techniques > Binary Search/Bisection

This is the story of Mr. and Mrs. A. They always love to play with integers. One day Mr. A asks Mrs. A to find any three integers X, Y, Z such that X = Y^Z (X, Y, Z>1). Mrs. A answers the question within 1 second. Mr. A wants to make the task harder for Mrs. A so Mr. A gives two more integers L, R. Now Mr. A asks find how many integers X, are present from L to R. Mrs. A never likes to loss to Mr. A. So Mrs. A seeks help from you. Can you do it for Mrs. A? Input: ------ First line gives an integer T (<=10^5), number of integers. Each line contains two integers L, R (1<=L<=R<=10^12) Output: ------- For every case, print case number and require answer. Look at sample output. Sample Input ------------ 2 4 9 10 20 Sample Output ------------- Case 1: 3 Case 2: 1 **Sample Input/output Explanation:** From 4 – 9 there are 3 numbers - 4 = 2^2, 8 = 2^3, 9 = 3^2 From 10 – 20 there is only one number – 16 = 2^4. 16 can also express as 16 = 4^2. But count for only once.

Shakil Ahmed

Language |
Time Limit (seconds) |

C | 3.00 |

C++ | 3.00 |

C++14 | 3.00 |

C# | 5.00 |

Go | 5.00 |

Java | 5.00 |

JavaScript | 5.00 |

Objective-C | 5.00 |

Perl | 5.00 |

PHP | 5.00 |

Python | 5.00 |

Python3 | 5.00 |

Ruby | 5.00 |

VB.Net | 5.00 |

Solve/Submission

# | User | Language | Timing |
---|---|---|---|

01 | feodorv | Cpp | 0.06s |

02 | rayhan50001 | Cpp14 | 0.14s |

03 | Morass | Cpp14 | 0.16s |

04 | twyu0721 | Cpp | 0.17s |

05 | AlirezaNa | Cpp14 | 0.44s |

06 | mpnri | Cpp | 0.45s |

07 | _c_k_r_ | Cpp | 0.62s |

08 | prateepm | Cpp14 | 0.91s |

09 | ssavi | Cpp14 | 0.96s |

10 | sakib_muhit | Cpp | 1.08s |

11 | Riaz_BSMRSTU | Cpp | 1.17s |

12 | Robbinb1993 | Cpp | 1.20s |

13 | seyedssz | Cpp14 | 1.24s |

14 | jalal | Cpp14 | 1.25s |

15 | atik | Cpp | 1.31s |

16 | abdulmukit | Cpp | 1.32s |

17 | kpretomazi | Cpp | 1.32s |

18 | rashedul007 | Cpp | 1.33s |

19 | mahmud2690 | Cpp | 1.34s |

20 | fncse | Cpp | 1.34s |

21 | t0whid | Cpp | 1.35s |

22 | Azaxdev | Cpp | 1.35s |

23 | rajdipsaha | Cpp | 1.36s |

24 | prodipdatta7 | Cpp14 | 1.37s |

25 | Sarwar05 | Cpp14 | 1.39s |

26 | sadia2427 | Cpp14 | 1.41s |

27 | haasib | Cpp14 | 1.41s |

28 | tariqiitju | Cpp14 | 1.47s |

29 | subhashis_cse | Cpp14 | 1.47s |

30 | KNUTH | Cpp14 | 1.47s |

31 | anowar1112 | Cpp14 | 1.47s |

32 | smriad | Cpp14 | 1.48s |

33 | ammasum | Cpp14 | 1.49s |

34 | ahqmrf | Cpp14 | 1.49s |

35 | prantacse14 | Cpp14 | 1.50s |

36 | hmtanbir | Cpp14 | 1.50s |

37 | ProKawsar | Cpp14 | 1.56s |

38 | emrul | Cpp14 | 1.56s |

39 | AlaminJust | Cpp14 | 1.57s |

40 | SakibAlamin | Cpp14 | 1.58s |

41 | bishal_biswas | Cpp14 | 1.59s |

42 | _dipu | Cpp14 | 1.60s |

43 | umli | Cpp14 | 1.67s |

44 | Ishrak | Cpp14 | 1.69s |

45 | dmehrab06 | Cpp14 | 1.72s |

46 | nazmulpcc | Cpp14 | 1.84s |

47 | sazal_dev | Cpp14 | 2.79s |

Copyright © 2015-2016 Dev Skill.

Feedback
#### Your feedback is our precious!

## Thank you for providing feedback! Our developers will be happy :)

## Sorry there was a problem when submitting the feedback. Please try again. :(