Editorial
Algorithm Analysis
Since , then and to calculate the result one should use the long long
type.
Algorithm Implementation
Read the input data. Calculate and output the answer.
scanf("%lld %lld", &a, &b); res = a * a + b * b; printf("%lld\n", res);
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
a, b = map(int,input().split()) 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); }