A. Arpa’s hard exam and Mehrdad’s naive cheat(Hard)

Codeforces
IDCF10118A
Time1000ms
Memory256MB
Difficulty
English · Original
Formal · Original
_There exists an island called Arpa’s land, some beautiful girls are living there, as ugly ones do._ Mehrdad wants to become minister of Arpa’s land. Arpa has prepared an exam. Exam has only one question, given n, print the last digit of 1378n. Mehrdad has become quite confused and wants you to help him. Please help, although it's a naive cheat. The single line of input contains one integer n (0  ≤  n  ≤  10106). Print single integer — the last digit of 1378n. In the first example, last digit of 13781 = 1378 is 8. In the second example, last digit of 13782 = 1378·1378 = 1898884 is 4. ## Input The single line of input contains one integer n (0  ≤  n  ≤  10106). ## Output Print single integer — the last digit of 1378n. [samples] ## Note In the first example, last digit of 13781 = 1378 is 8.In the second example, last digit of 13782 = 1378·1378 = 1898884 is 4.
**Definitions** Let $ n \in \mathbb{Z} $, $ 0 \leq n \leq 10^{106} $. **Objective** Compute the last digit of $ 1378^n $, i.e., find $ 1378^n \mod 10 $.
API Response (JSON)
{
  "problem": {
    "name": "A. Arpa’s hard exam and Mehrdad’s naive cheat(Hard)",
    "description": {
      "content": "_There exists an island called Arpa’s land, some beautiful girls are living there, as ugly ones do._ Mehrdad wants to become minister of Arpa’s land. Arpa has prepared an exam. Exam has only one ques",
      "description_type": "Markdown"
    },
    "platform": "Codeforces",
    "limit": {
      "time_limit": 1000,
      "memory_limit": 262144
    },
    "difficulty": "None",
    "is_remote": true,
    "is_sync": true,
    "sync_url": null,
    "sign": "CF10118A"
  },
  "statements": [
    {
      "statement_type": "Markdown",
      "content": "_There exists an island called Arpa’s land, some beautiful girls are living there, as ugly ones do._\n\nMehrdad wants to become minister of Arpa’s land. Arpa has prepared an exam. Exam has only one ques...",
      "is_translate": false,
      "language": "English"
    },
    {
      "statement_type": "Markdown",
      "content": "**Definitions**  \nLet $ n \\in \\mathbb{Z} $, $ 0 \\leq n \\leq 10^{106} $.  \n\n**Objective**  \nCompute the last digit of $ 1378^n $, i.e., find $ 1378^n \\mod 10 $....",
      "is_translate": false,
      "language": "Formal"
    }
  ]
}
Full JSON Raw Segments