A. Arpa’s hard exam and Mehrdad’s naive cheat

Codeforces
IDCF742A
Time1000ms
Memory256MB
Difficulty
implementationmathnumber theory
English · Original
Chinese · Translation
Formal · Original
_There exists an island called Arpa’s land, some beautiful girls live 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 1378_n_. <center>![image](https://espresso.codeforces.com/ac805c7c78540a009fed5a8407fb3448d2a085a6.png)</center>Mehrdad has become quite confused and wants you to help him. Please help, although it's a naive cheat. ## Input The single line of input contains one integer _n_ (0  ≤  _n_  ≤  109). ## Output Print single integer — the last digit of 1378_n_. [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.
_存在一个名为 Arpa 土地的岛屿,那里住着一些美丽的女孩,也有丑陋的女孩。_ Mehrdad 想成为 Arpa 土地的部长。Arpa 准备了一场考试,考试只有一道题:给定 #cf_span[n],请输出 #cf_span[1378n] 的最后一位数字。 Mehrdad 感到非常困惑,希望你帮助他。请帮帮他吧,尽管这只是一个简单的作弊方法。 输入的唯一一行包含一个整数 #cf_span[n](#cf_span[0  ≤  n  ≤  109])。 请输出一个整数 —— #cf_span[1378n] 的最后一位数字。 在第一个例子中,#cf_span[13781 = 1378] 的最后一位数字是 #cf_span[8]。 在第二个例子中,#cf_span[13782 = 1378·1378 = 1898884] 的最后一位数字是 #cf_span[4]。 ## Input 输入的唯一一行包含一个整数 #cf_span[n](#cf_span[0  ≤  n  ≤  109])。 ## Output 请输出一个整数 —— #cf_span[1378n] 的最后一位数字。 [samples] ## Note 在第一个例子中,#cf_span[13781 = 1378] 的最后一位数字是 #cf_span[8]。在第二个例子中,#cf_span[13782 = 1378·1378 = 1898884] 的最后一位数字是 #cf_span[4]。
**Definitions** Let $ n \in \mathbb{Z} $, $ 0 \leq n \leq 10^9 $. **Objective** Compute the last digit of $ 1378^n $, i.e., compute $ 1378^n \mod 10 $.
Samples
Input #1
1
Output #1
8
Input #2
2
Output #2
4
API Response (JSON)
{
  "problem": {
    "name": "A. Arpa’s hard exam and Mehrdad’s naive cheat",
    "description": {
      "content": "_There exists an island called Arpa’s land, some beautiful girls live there, as ugly ones do._ Mehrdad wants to become minister of Arpa’s land. Arpa has prepared an exam. Exam has only one question, ",
      "description_type": "Markdown"
    },
    "platform": "Codeforces",
    "limit": {
      "time_limit": 1000,
      "memory_limit": 262144
    },
    "difficulty": "None",
    "is_remote": true,
    "is_sync": true,
    "sync_url": null,
    "sign": "CF742A"
  },
  "statements": [
    {
      "statement_type": "Markdown",
      "content": "_There exists an island called Arpa’s land, some beautiful girls live there, as ugly ones do._\n\nMehrdad wants to become minister of Arpa’s land. Arpa has prepared an exam. Exam has only one question, ...",
      "is_translate": false,
      "language": "English"
    },
    {
      "statement_type": "Markdown",
      "content": "_存在一个名为 Arpa 土地的岛屿,那里住着一些美丽的女孩,也有丑陋的女孩。_\n\nMehrdad 想成为 Arpa 土地的部长。Arpa 准备了一场考试,考试只有一道题:给定 #cf_span[n],请输出 #cf_span[1378n] 的最后一位数字。\n\nMehrdad 感到非常困惑,希望你帮助他。请帮帮他吧,尽管这只是一个简单的作弊方法。\n\n输入的唯一一行包含一个整数 #cf_span[n...",
      "is_translate": true,
      "language": "Chinese"
    },
    {
      "statement_type": "Markdown",
      "content": "**Definitions**  \nLet $ n \\in \\mathbb{Z} $, $ 0 \\leq n \\leq 10^9 $.  \n\n**Objective**  \nCompute the last digit of $ 1378^n $, i.e., compute $ 1378^n \\mod 10 $....",
      "is_translate": false,
      "language": "Formal"
    }
  ]
}
Full JSON Raw Segments