Author Ahmed_Mahmoudno.1
Soltan's Flower
Think about the properties of the number.
What does dividing by 2 tell you?
Check the remainder when dividing by 2.
If the number is even, print REAL. If the number is odd, print FAKE.
#include <iostream>
using namespace std;
int main() {
int n;
cin >> n;
if((n % 2) == 0){
cout << "REAL" << endl;
}else{
cout << "FAKE" << endl;
}
}
==================
Problem 2
You are given a circle's radius and a square's side length, figure out the relation between them.
Can the circle fit inside the square? Compare the diameter with the side length.
Diameter of a circle is 2*r and the diagonal of the square is l × √2..
If the diameter of the circle is less than the side of the square, the circle fits inside the square.
If the diagonal of the square (l × √2) is less than the diameter, the square fits inside the circle.
Otherwise, output -1.
#include <iostream>
using namespace std;
int main() {
int r, l;
cin >> r >> l;
if((r * 2) < l){
cout << "circle on a square" << endl;
}else if((l * l) < (r*r * 2)){
cout << "square on a circle" << endl;
}else{
cout << -1 << endl;
}
}
==================
Toxic Soltan
The real hour repeats every 12 hours.
Think about how to "undo" adding multiples of 12.
Use the modulus operation with 12, but handle the case where the result is 0.
Since Soltan added some multiple of 12 to his real hour, we can recover the real hour by taking n % 12. If the result is 0, the real hour is 12 itself.
#include <iostream>
using namespace std;
int main() {
int n;
cin >> n;
if((n % 12) == 0){
cout << 12 << endl;
}else{
cout << n % 12 << endl;
}
}
==================
Baskota and Math
You don't need to store the entire number — just read it smartly.
The number can have up to 10^7 digits, so it can't fit in any standard integer type.
Read the number character by character — you only need the first one.
Since the number can be up to 10^7 digits long, we can't use int or even long long. Read n, then read just the first character of the number directly into a char and print it.
#include <iostream>
using namespace std;
int main() {
int n;
char A;
cin >> n >> A;
cout << A << endl;
}
==================
Soltan and the Great Wall
There are two independent ways Soltan can cross the wall — check each one separately.
For Way 1, Soltan needs both enough strength AND enough height. For Way 2, he needs the magic tool AND enough strength.
Combine both conditions with OR — if either way works, Soltan reaches Baskota.
Check Way 1: strength ≥ 70 and height ≥ 60. Check Way 2: magicTool = 1 and strength ≥ 50. If either condition is true, print "Soltan saved Baskota!", otherwise print "Soltan is crying behind the wall :(".
#include <iostream>
using namespace std;
int main() {
int a, b, c;
cin >> a >> b >> c;
if((a >= 70 && b >= 60) || (c == 1 && a >= 50)){
cout << "Soltan saved Baskota!" << endl;
}else{
cout << "Soltan is crying behind the wall :(" << endl;
}
}
==================
Soltan and the Magical Door
Extract the three digits of the number separately.
Use division and modulo to get the hundreds, tens, and units digits.
Check all three combinations: does a+b=c, b+c=a, or a+c=b?
Extract the digits: units = n%10, tens = (n/10)%10, hundreds = n/100. Then check if any two digits sum to the third. If any combination holds, the door opens.
#include <iostream>
using namespace std;
int main() {
int n;
cin >> n;
int a = n % 10,
b = (n / 10) % 10,
c = n / 100;
if (a + b == c || b + c == a || a + c == b){
cout << "the door opens" << endl;
}else{
cout << "the door remains closed" << endl;
}
}
==================
Baskota's Husband
You need to find boys who are strictly taller than Baskota.
Among all valid boys, you want the one closest to Baskota's height.
Track the minimum height among boys who are strictly taller than Baskota. If none exist, output -1.
Read Baskota's height a and the three boys' heights b, c, d. Give a defualt value and if not changed after conditions ,this means that there is no valid boy. For each boy, check if his height is strictly greater than a. Among all valid boys, keep track of the minimum. If no valid boy exists, print -1.
#include <iostream>
using namespace std;
int main() {
int a, b, c, d;
cin >> a >> b >> c >> d;
int answer = 201;
if(a < b && b < answer) answer = b;
if(a < c && c < answer) answer = c;
if(a < d && d < answer) answer = d;
if(answer < 201){
cout << answer << endl;
}else{
cout << -1 << endl;
}
}
==================
Baskota's Test
Try computing f(n) for small values and look for a pattern based on whether n is odd or even.
When n is even, pairs (-1+2), (-3+4), ... each contribute +1, giving n/2 total.
When n is odd, it's like the even case for n-1, minus the last term n. Use the pattern to derive a closed formula. Also, n can be up to 10^15 — use long long!
If n is even: f(n) = n/2. If n is odd: f(n) = -(n+1)/2. This follows from grouping pairs of terms. Since n can reach 10^15, int is not sufficient — use long long.
#include <iostream>
using namespace std;
int main() {
long long n;
cin >> n;
if((n % 2) == 0){
cout << n / 2 << endl;
}else{
cout << -(n + 1) / 2 << endl;
}
}



