Codeforces: A. Vasya and the Bus


This problem is from http://www.codeforces.com/problemset/problem/190/A

190A Codeforces: A. Vasya and the Bus beginner codeforces math python

It is a pure math problem. However, you have to be careful enough to consider different cases. For example, if there are no adults, there should not be any children (unless 0 children, so in this case output two zeros). If there are no children, the output are two identical number, which is n. Try to think how many tickets can be free, and substract this number from the total number of people, which should not be too difficult.

The python solution is presented below.

s = raw_input("").split(" ")

n = int(s[0])
m = int(s[1])

if n == 0:
    if m == 0:
        print 0, " ", 0
    else:
        print "Impossible"
elif m <= 1:
    print n, " ", n
elif (n == m):
    print n, " ", 2 * n - 1
elif (n > m):
    print n, " ", n - 1 + m
else:
    print m, " ", n + m - 1

–EOF (The Ultimate Computing & Technology Blog) —

GD Star Rating
loading...
271 words
Last Post: Using COM object in Python
Next Post: Codeforces: A. Sleuth

The Permanent URL is: Codeforces: A. Vasya and the Bus

Leave a Reply