PROBLEM LINK:
Author: Full name
Tester: Full name
Editorialist: Oleksandr Kulkov
DIFFICULTY:
CAKEWALK
PREREQUISITES:
None
PROBLEM:
You have to interactively participate in Monty Hall’s show. There are three doors, only one of them having prize behind it. You choose some door X, then game host tells you door Y such that Y\neq X and Y doesn’t have a prize behind it. You have to choose between two doors final door Z which
EXPLANATION:
From wikipedia article you may read that choosing different door will always give you better chance (\tfrac 1 2 instead of \tfrac 1 3 with initial door). So, you may ask any door X and after you read Y to write number Z such that Z \neq X and Z \neq Y. One of short ways to do that:
cout << 1 << endl;
int x;
cin >> x;
cout << (x ^ 1) << endl;
AUTHOR’S AND TESTER’S SOLUTIONS:
Author’s solution can be found here.
Tester’s solution can be found here.