# ECLIPSE Editorial

Contest

Author: Rutvij Menavlikar
Tester: Ishaan Shah, Sanyam Shah, Sambasai Andem and Tejas Chaudhari
Editorialist: Rutvij Menavlikar

EASY

# EXPLANATION:

The keywords in the poem were Apollo, Luna and if that was not enough, First.
Apollo and Luna signify the Apollo 11 mission to the moon. And if that was not clear, First signified the first manned mission to the moon. It also signifies the first man to walk on the moon, i.e., Neil Armstrong.
So the solution was to check if the number is an Armstrong number or not.

# ALTERNATE EXPLANATION:

Apollo and Eclipse refer to an article where the crew of Apollo 11 saw a total solar eclipse from space.
And Apollo 11 leads to Neil Armstrong and that leads to Armstrong numbers.

# SOLUTIONS:

Setter's Solution
``````#include <iostream>
#include <vector>

using namespace std;

#define ll long long

ll pw(ll a, ll b)
{
ll ans = (a > 0);
while (b--)
ans *= a;
return ans;
}

int main()
{
int t;
cin >> t;
while (t--)
{
ll n;
cin >> n;
vector<int> dig;
ll temp = n;
while (temp > 0)
{
dig.push_back(temp % 10);
temp /= 10;
}
ll arm = 0;
for (auto x : dig)
arm += pw(x, (ll)dig.size());
if (arm == n)
cout << "yes\n";
else
cout << "no\n";
}
return 0;
}
``````
Tester's Solution
``````#include <bits/stdc++.h>
using namespace std;
#define fast                      \
ios_base::sync_with_stdio(0); \
cin.tie(0);                   \
cout.tie(0)
#define pb push_back
#define tc    \
int t;    \
cin >> t; \
while (t--)

// computes a^b is log(a) time
long long binexp(long long a, long long b)
{
long long res = 1;
while (b > 0)
{
if (b & 1)
res = res * a;
a = a * a;
b >>= 1;
}
return res;
}

signed main()
{
fast;
tc
{
long long n, n1;
cin >> n;
n1 = n;
long long c = 0;
vector<long long> v;
while (n > 0)
{
c++;
v.pb(n % 10);
n /= 10;
}
long long ans = 0;
for (long long i = 0; i < v.size(); i++)
{
ans += binexp(v[i], c);
}
if (ans == n1)
{
cout << "yes" << endl;
}
else
{
cout << "no" << endl;
}
}
}
``````
Editorialist's Solution
``````def is_armstrong(n):
armstrong = 0
inp = str(n)
for c in inp:
armstrong += int(c)**len(inp)

if armstrong == n:
return True
else:
return False

if __name__ == "__main__":
t = int(input())
for _ in range(t):
inp = input()
n = int(inp)
if is_armstrong(n):
print("yes")
else:
print("no")
``````