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

Solution of 10684- The jckpot

Problem description:
source: https://uva.onlinejudge.org/external/106/10684.html

As Manuel wants to get rich faster and without too much work, he decided to make a career in gambling. Initially, he plans to study the gains and losses of players, so that, he can identify patterns of consecutive wins and elaborate a win-win strategy. But Manuel, as smart as he thinks he is, does not know how to program computers. So he hired you to write programs that will assist him in elaborating his strategy. 

Your first task is to write a program that identifies the maximum possible gain out of a sequence of bets. A bet is an amount of money and is either winning (and this is recorded as a positive value), or losing (and this is recorded as a negative value).

image

Solution of 10696 - f91

Problem Description
source:https://uva.onlinejudge.org/external/106/10696.html

McCarthy is a famous theorician of computer science. In his work, he defined a recursive function, called f91, that takes as input a positive integer N and returns a positive integer defined as follows:
       • If N ≤ 100, then f91(N) = f91(f91(N + 11)); 
       • If N ≥ 101, then f91(N) = N − 10. 

Write a program, that computes McCarthy’s f91. 

image