# C# – Algorithms – Arpa’s hard exam and Mehrdad’s naive cheat

As mentioned some times ago, whenever I am looking for a subject to post, the easiest way is to go to Codeforces.com and simply take a problem from the second division. If I manage to solve it from the first time, I write that it was an interesting problem and if I have to make 3-4 submits, I usually write that it is more than interesting.

This time, we have an interesting problem – I managed to solve it from the first submit, and yet it seemed tough somehow

The idea was to guess the last digit of 1378, put on the power of an input, up to 10^9. As you probably see, this is something really big, thus it would be slow. That’s why I built something like this in excel, just to see how the last digits of 8 change, when we increase the power.

Pretty much, we have 5 cases – when the input is 0, and one for division with remainder 0, 1, 2 and 3. Thus the code was written without debugging and simply submitted.

Here comes the code:

No science fiction, it works! 🙂

Tagged with: