Sum of two numbers
Two integers a and b are given on one line, separated by a space.
Print a + b.
- Input
- -1,000,000,000,000 ≤ a, b ≤ 1,000,000,000,000
- Output
- a + b on one line
3 4
7
2000000000 2000000000
4000000000
Two integers a and b are given on one line, separated by a space.
Print a + b.
3 4
7
2000000000 2000000000
4000000000
When you run, these lines are fed to input()/stdin in order (the program doesn't stop to ask).
$ Ready
Open this on a computer to write and run code. On mobile you can read the problem and the solutions.
In C, C++, Java and C#, reading into a 32-bit int (about ±2.1 billion) overflows on the second example — use long / long long.
Python has no size limit, and JavaScript, TypeScript and Craykon use a single double-precision number type that is exact up to 2^53 (about 9×10^15), so they work in this range.
a, b = map(int, input().split())print(a + b)const [a, b] = require("fs").readFileSync(0, "utf8").trim().split(/\s+/).map(Number);console.log(a + b);import { readFileSync } from "node:fs";const [a, b]: number[] = readFileSync(0, "utf8").trim().split(/\s+/).map(Number);console.log(a + b);import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); long a = sc.nextLong(), b = sc.nextLong(); System.out.println(a + b); }}using System; class Program{ static void Main() { long[] v = Array.ConvertAll(Console.ReadLine().Split(' ', StringSplitOptions.RemoveEmptyEntries), long.Parse); Console.WriteLine(v[0] + v[1]); }}#include <iostream> int main() { long long a, b; std::cin >> a >> b; std::cout << a + b << '\n';}#include <stdio.h> int main(void) { long long a, b; scanf("%lld %lld", &a, &b); printf("%lld\n", a + b); return 0;}수들 = Console.ReadNumbers();Console.WriteLine(수들[0] + 수들[1]);