DCP-204: Shooting Game Back to All Problems

Medium Beginners Problems > Ad-hoc


Shooting Game is a very dangerous game. There are **N** persons who stand forming a circle. Everyone has a unique ID number **(1 to N)**. They stand in there serially clockwise. Another man with a gun stands in the center of that circle. He starts shooting one by one in clock wise direction. But there are some rules. He doesn't shoot two consecutive alive person. He always starts from the person with ID 1. On starting round, ID 1 survives ID 2 dies ID 3 survives ID 4 dies ID 5 survives and the so on. The game continues until only one person survives. Like for **N = 10**, the Shooting order will be **2 -> 4 -> 6 -> 8 -> 10 -> 3 -> 7 -> 1 -> 9** and the person with ID 5 is set to free. Consider a function **F(N)** which takes the number of the persons (excluding the shooter) as parameter and returns the ID of the person who survives in the end. Mr. Sifat Shishir, a famous mathematician wonders, given a range **A** to **B** (inclusive), how many integers are there for which **F(N) = N/2**. Input: ------ First line of input consists of one integer **T (T<=10^4)**, that denotes the number of test case. Then next T lines follow. Each line have two integers **A** & **B**. **( 1 <=A <= B <= 10^18)** Output: ------- For each test case print a line "**Case t: C**" without quotes where t is the case number and C is the number of integers for which **F(N) = N/2** Sample Input ------------ 2 1 5 1 10 Sample Output ------------- Case 1: 1 Case 2: 2


Problem Setter:

Md. Samiul Alam

Please login to submit solution to this problem.

Problem Limits

Language Time Limit (seconds)
C 1.00
C++ 1.00
C++14 1.00
C# 3.00
Go 3.00
Java 3.00
JavaScript 3.00
Objective-C 3.00
Perl 3.00
PHP 3.00
Python 3.00
Python3 3.00
Ruby 3.00
VB.Net 3.00

Problem Stats

53/152

Solve/Submission

Ranking

# User Language Timing
01 akazad_cse13_ruet Cpp14 0.00s
02 shakil_ruet Cpp14 0.00s
03 siamcr7 Cpp14 0.00s
04 Biprodas Cpp14 0.00s
05 feodorv Cpp14 0.00s
06 Robbinb1993 Cpp14 0.00s
07 shawon100 Cpp14 0.01s
08 seyedssz Cpp14 0.01s
09 Morass Cpp14 0.01s
10 Saadmaan007 Cpp14 0.01s
11 rayhan50001 Cpp14 0.01s
12 Hasinur_ Cpp14 0.01s
13 SKL12 Cpp14 0.02s
14 saiful130104 Cpp14 0.02s
15 Protap_Ghose Cpp14 0.03s
16 saurabh3240 Cpp14 0.28s
17 zahid119 Cpp14 0.28s
18 nasif2587 Cpp14 0.39s
19 Saimum_140128 Cpp14 0.39s
20 PKP_007 Cpp14 0.40s
21 ssavi Cpp14 0.40s
22 robincse14 Cpp14 0.41s
23 shuvo1862 Cpp14 0.42s
24 Arpan_cse_2k14 Cpp14 0.42s
25 Mr_adnan Cpp14 0.42s
26 KIRIN_36 Cpp14 0.43s
27 sumon23 Cpp14 0.46s
28 abuasifkhan Cpp14 0.48s
29 imAnik Cpp14 0.49s
30 tariqiitju Cpp14 0.50s
31 nabil1997 Cpp14 0.50s
32 a_pramanik Cpp14 0.50s
33 jalal Cpp14 0.50s
34 prodipdatta7 Cpp14 0.51s
35 zyyxxx Cpp14 0.52s
36 murad_al_wajed Cpp14 0.53s
37 Tanmoy_Datta Cpp14 0.54s
38 xpo6 Cpp14 0.54s
39 souravvv Cpp14 0.55s
40 sazal_dev Cpp14 0.55s
41 skmonir Cpp14 0.56s
Feedback

Your feedback is our precious!



Or call +88 02 9853138 for support