Official
A - Three Dice Editorial by KoD
サイコロは「ある面とその反対側の面が表す整数を足すと \(7\) になる」という性質を持ちます。よって、\(n\) の目が出たとき、反対側の面が表す整数は \(7 - n\) です。
したがって答えは \((7 - a) + (7 - b) + (7 - c) = 21 - (a + b + c)\) となるので、これを出力すればよいです。
C++ での実装例:
#include <iostream>
int main() {
int a, b, c;
std::cin >> a >> b >> c;
std::cout << 21 - (a + b + c) << '\n';
return 0;
}
Python での実装例:
a, b, c = map(int, input().split())
print(21 - (a + b + c))
Rust での実装例:
use proconio::input;
fn main() {
input!(num: [i32; 3]);
println!("{}", 21 - num.into_iter().sum::<i32>());
}
posted:
last update: