Showing posts with label away. Show all posts
Showing posts with label away. Show all posts

Tuesday, August 30, 2016

UVa 10940 Throwing Cards Away II

UVa 10940 Throwing Cards Away II


This is a problem of case study and math. Create a program that simulates the process and find the pattern.

Inputs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
Outputs:
1
2
2
4
2
4
6
8
2
4
6
8
10
12
14
16
2
4
6
8
10
12
14
16
18
20
22
24
26
28
30
32

Once you find the pattern its straightforward.
1. Find the nearest 2^X such that 2^X <= N
2. If 2^X == N, output N
    Else output (N-2^X)*2

Go to link download

Read more »