Official

A - Three Dice Editorial by en_translator


The sum of numbers of opposite faces of a dice is always \(7\). Therefore, when the number written on a face is \(n\), the number on the opposite face is \(7 - n\).

Therefore, the answer is \((7 - a) + (7 - b) + (7 - c) = 21 - (a + b + c)\), so it is enough to output this.

Sample Code in C++:

#include <iostream>

int main() {
    int a, b, c;
    std::cin >> a >> b >> c;
    std::cout << 21 - (a + b + c) << '\n';
    return 0;
}

Sample Code in Python:

a, b, c = map(int, input().split())
print(21 - (a + b + c))

Sample Code in Rust:

use proconio::input;

fn main() {
	input!(num: [i32; 3]);
  	println!("{}", 21 - num.into_iter().sum::<i32>());
}

posted:
last update: