The Treasure Key
Annoula and her brother Totos, while searching in the attic of their house for some old photo albums, discovered a forgotten chest. Inside the chest, there is an old map that once belonged to the legendary pirate Henry Every. According to the map, a precious treasure is hidden somewhere on the island, but to reach it, they must solve three puzzles.
Annoula and Totos are curious to see what the chest contains. However, they must first open the lock.
Puzzle 1
At the bottom of the chest, there are two numbers engraved.
Next to these numbers, the pirate had also engraved a note:
«1. My crew consists of as many sailors as the product of the two numbers engraved here.
If you manage to find the product and enter the number in the lock, the chest will open!»
Puzzle 2
A little further down, it says:
«2. Once you open the chest, you only need to find where the treasure is hidden on the map.
From the numbers and , either , , or both and might be .
However, it's possible that neither of them is .
- If neither is , the treasure is hidden under the number on the map,
- If only is , the treasure is hidden under the number on the map,
- If only is , the treasure is hidden under the number on the map,
- If both and are , the treasure is hidden under the number on the map»
Totos and Annoula need your help because they're quite stressed and need to verify that they're doing the right calculations to eventually find the treasure!
We want to write a program that reads from input STDIN two integers, and (both positive, single-digit numbers), separated by a newline character ('\n'
), and prints two lines in the output STDOUT.
In the first line, the program should print the product of and .
In the second line, the program should print one of the numbers , , , or based on the pirate's note 2.
Examples
1st
Input (STDIN)
6
8
Output (STDOUT)
48
0
Explanation of the first example:
The crew of the captain consists of sailors, and neither of the two numbers is , so the output is 0.
2nd
Input (STDIN)
0
3
Output (STDOUT)
0
1
Explanation of the second example:
The crew of the captain consists of sailors, and the first number, , is , so the output is 1.
Note! Each line of input and output (should) end with a newline character '\n'
.
Here is the translation of the last part:
A Little Cheat Sheet!
Python:
from sys import exit
# The execution of the program starts here!
if __name__ == "__main__":
x = int(input())
if(x == 1) : ...
elif(x == 2) : ...
exit(0)
C/C++ (με cstdio
):
#include <stdio.h>
// The execution of the program starts here!
int main() {
int x;
scanf("%d", &x);
if(x == 1){...}
else if(x == 2){...}
return 0;
}
C++ (με iostream
):
#include <iostream>
// The execution of the program starts here!
int main() {
int x;
std::cin >> x; // Use std::cin for input
if (x == 1) {
// Add your code for x == 1 here
} else if (x == 2) {
// Add your code for x == 2 here
}
return 0;
}
Comments