You can choose two different fruits in one of the following ways:
a banana and an apple in a \cdot b ways;
a banana and a pear in a \cdot c ways;
an apple and a pear in b \cdot c ways;
Thus, you can select two different fruits in a \cdot b + a \cdot c + b \cdot c ways. Considering that a, b, c \le 10^6, the answer will be no more than 3 \cdot 10^{12}. You should use the long long type.
Algorithm implementation
Read the input data.
scanf("%lld %lld %lld",&a,&b,&c);Compute and print the answer.
res = a * b + a * c + b * c;
printf("%lld\n",res);Java implementation
import java.util.*;
class Main
{
public static void main(String[] args)
{
Scanner con = new Scanner(System.in);
long a = con.nextLong();
long b = con.nextLong();
long c = con.nextLong();
long res = a * b + a * c + b * c;
System.out.println(res);
con.close();
}
}Python implementation
Read the input data.
a, b, c = map(int,input().split())Compute and print the answer.
res = a * b + a * c + b * c
print(res)