# ECLIPSE Editorial

**URL:** <https://discuss.codechef.com/t/eclipse-editorial/100260>\
**Category:** editorial\
**Tags:** math\
**Created:** [March 28, 2022, 9:00pm UTC](https://discuss.codechef.com/t/eclipse-editorial/100260 "2022-03-28T21:00:38Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![rutvij1](https://www.codechef.com/sites/all/themes/abessive/images/user_default_thumb.jpg) [@rutvij1](https://discuss.codechef.com/u/rutvij1)\
**Post date:** [March 28, 2022, 9:00pm UTC](https://discuss.codechef.com/t/eclipse-editorial/100260/1 "2022-03-28T21:00:38Z")

</div>

# PROBLEM LINK:

[Contest](https://www.codechef.com/FOOL2022/problems/ECLIPSE)

_ **Author:** _ [Rutvij Menavlikar](https://www.codechef.com/users/rutvij1)  
_ **Tester:** _ [Ishaan Shah](https://www.codechef.com/users/ishaanshah), [Sanyam Shah](https://www.codechef.com/users/mash_28), [Sambasai Andem](https://www.codechef.com/users/sambasai) and [Tejas Chaudhari](https://www.codechef.com/users/kryptai)  
_ **Editorialist:** _ [Rutvij Menavlikar](https://www.codechef.com/users/rutvij1)

# DIFFICULTY:

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](https://en.wikipedia.org/wiki/Neil_Armstrong).  
So the solution was to check if the number is an [Armstrong number](https://en.wikipedia.org/wiki/Narcissistic_number) or not.

# ALTERNATE EXPLANATION:

**Apollo** and **Eclipse** refer to an [article](https://www.forbes.com/sites/jamiecartereurope/2019/07/19/the-apollo-11-crew-saw-something-incredible-on-their-way-to-the-moon-that-no-one-ever-mentions/?sh=5f506e6d6486) 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**
>
> ```cpp
> #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**
>
> ```cpp
> #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**
>
> ```python
> 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")
> 
> ```
