题目描述:
Fedya studies in a gymnasium. Fedya's maths hometask is to calculate the following expression:
(1^n + 2^n + 3^n + 4^n) mod 5
for given value of n. Fedya managed to complete the task. Can you? Note that given number n can be extremely large (e.g. it can exceed any integer type of your programming language).
大意:
费迪亚在体育馆学习。Fedya的数学作业是计算以下表达式:
(1^n + 2^n + 3^n + 4^n)mod 5
对于给定的n值,Fedya成功完成了任务。你能?注意,给定的数字n可以非常大(例如,它可以超过编程语言的任何整数类型)。
输入格式:
The single line contains a single integer n (0 ≤ n ≤ 10^10^5). The number doesn't contain any leading zeroes.
单行包含单个整数n(0 ≤ n ≤ 10^10^5). 该数字不包含任何前导零。
输出格式:
Print the value of the expression without leading zeros.
打印不带前导零的表达式值。
输入输出样例
Sample 1
Input
4
Output
4
Sample 2
Input
124356983594583453458888889
Output
0
思路:
发现规律2,3,4的n次方个位数都是4为循环,所以只需根据n的后两位,讨论4种情况
代码: