← Back to topics
Topic

New Languages

a
adminModerator
Python, Perl, PHP, Ruby, Fortran, Scheme, Basic

There is a different policy about the time/memory limits for each of the languages:

Python: Time [[x2]], Mem + [[20M]]

import sys, string

s = sys.stdin.readline().strip()
x = string.split(s, " ")
print int(x[0])+int(x[1])


PHP: Time [[x2]], Mem [[256M Fixed]]

<?PHP

$f = fopen('php://stdin', 'r');
$line = fgets($f);
$x = explode(" ", $line);
echo ((int)$x[0] + (int)$x[1])."n";

?>


Perl:Time [[x2]], Mem + [[20M]]

my $str = <STDIN>;
chomp($str);
my @nums = split / /,$str;
my $sum = $nums[0] + $nums[1];
print "$sumn";


Ruby: Time [[x2]], Mem + [[20M]]

s = gets
a = s.split(" ")
x = Integer(a[0])
y = Integer(a[1])
puts (x+y)


Scheme: Time [[x2]], Mem [[256M Fixed]]

(let
((a (read)) (b (read)))
(display (+ a b))
(display "n"))


Fortran: Same limits

program zbir
integer a, b, s
read *, a, b
s = a + b
print *, s
end


Basic:Time [[x2]], Mem + [[256M Fixed]]

INPUT "" a, b
PRINT a + b