Editorial
Since , then . Therefore, to compute the result, the long long type should be used.
Algorithm implementation
Read the input data.
scanf("%lld %lld",&a,&b);
Compute and print the answer.
res = a * a + b * b; printf("%lld\n",res);
Algorithm implementation — STL
#include <iostream> using namespace std; long long res, a, b; int main(void) { cin >> a >> b; res = a * a + b * b; cout << res << endl; return 0; }
Java implementation
import java.util.*; public class Main { public static void main(String []args) { Scanner con = new Scanner(System.in); long a = con.nextLong(); long b = con.nextLong(); long res = a*a + b*b; System.out.println(res); con.close(); } }
Python implementation
Read the input data.
a, b = map(int,input().split())
Compute and print the answer.
res = a**2 + b**2 print(res)
Go implementation
package main import "fmt" func main() { var a, b, res int64 fmt.Scanf("%d %d", &a,&b) res = a * a + b * b fmt.Println(res) }