I'm beginner in Python and I'm trying to read two numbers in a simple programming contest problem.
# Codeforces New Year 2013 Contest;
# http://codeforces.com/contest/379/problem/A
import sys;
def main ():
a = input ();
b = input ();
resto = 0;
result = 0;
while (a > 0):
a-=1
result += 1;
resto += 1;
if (resto >= b):
resto -= b;
a += 1;
print result;
main ();
if I try to run the program with 4 2 (separated by a blank space), I get the following error:
ValueError: invalid literal for int() with base 10: '4 2'
But if I type 4 [enter] and then 2 [enter], the program runs without any problems.
How do I read from stdin in python just like C++ does?
Edit: Sorry for the mess! I usually run a code with input this way:
C++: ./main < test
Python: python main.py < test