Showing posts with label Volume I. Show all posts
Showing posts with label Volume I. Show all posts

Solution of 136 - Ugly Numbers

Problem Description
source:https://uva.onlinejudge.org/external/1/136.html

Ugly numbers are numbers whose only prime factors are 2, 3 or 5. The sequence 
          1, 2, 3, 4, 5, 6, 8, 9, 10, 12, 15, ... 
shows the first 11 ugly numbers. By convention, 1 is included. 
         Write a program to find and print the 1500’th ugly number. 

Input 

There is no input to this program. 

image

113 - Power of Cryptography

Problem Description
source: https://uva.onlinejudge.org/external/1/113.html

Current work in cryptography involves (among other things) large prime numbers and computing powers of numbers modulo functions of these primes. Work in this area has resulted in the practical use of results from number theory and other branches of mathematics once considered to be of only theoretical interest. 
    This problem involves the efficient computation of integer roots of numbers. 

    Given an integer n ≥ 1 and an integer p ≥ 1 you are to write a program that determines n√p, the positive n-th root of p. In this problem, given such integers n and p, p will always be of the form kn for an integer k (this integer is what your program must find).

image

102- Ecological Bin Packing

Problem Description
source: https://uva.onlinejudge.org/external/1/p102.html

Bin packing, or the placement of objects of certain weights into different bins subject to certain constraints, is an historically interesting problem. Some bin packing problems are NP-complete but are amenable to dynamic programming solutions or to approximately optimal heuristic solutions.
    In this problem you will be solving a bin packing problem that deals with recycling glass.

    Recycling glass requires that the glass be separated by color into one of three categories: brown glass, green glass, and clear glass. In this problem you will be given three recycling bins, each containing a specified number of brown, green and clear bottles. In order to be recycled, the bottles will need to be moved so that each bin contains bottles of only one color.
image

100 - The 3n + 1 problem

 Problem description
source:https://uva.onlinejudge.org/external/1/p100.html

Problems in Computer Science are often classified as belonging to a certain class of problems (e.g., NP, Unsolvable, Recursive). In this problem you will be analyzing a property of an algorithm whose classification is not known for all possible inputs.

Consider the following algorithm:
1. input n
2. print n
3. if n = 1 then STOP
4. if n is odd then n ←− 3n + 1
5. else n ←− n/2
6. GOTO 2

Given the input 22, the following sequence of numbers will be printed

image