Fedya studies in a gymnasium. Fedya's maths hometask is to calculate the following expression:
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).
The single line contains a single integer n (0 ≤ n ≤ 10105). The number doesn't contain any leading zeroes.
Print the value of the expression without leading zeros.
4
4
124356983594583453458888889
0
Operation x mod y means taking remainder after division x by y.
Note to the first sample:
解题思路:
做这道题时各种气愤!!!题意好理解,规律也好推,我10分钟左右就把规律退出来了(刚开始以为是数论,
后来输出1到9发现是有规律的)。
但是由于它特意强调了n是一个非常大的数,So接下来的一个多小时,我就硬着头皮照着模板敲高精度除以低
精度,最后还是超时了·······坑啊!!!
规律就是如果n%4等于0的话,输出4,否则输出0·····多输出几组就看出来了。最后还是那句话:规律好找,题
分析错了才是真坑!!!
完整代码:
#include <stdio.h>
int x;
int main()
{
#ifdef DoubleQ
freopen("in.txt","r",stdin);
#endif
while(~scanf("%d",&x))
{
if(x % 4 == 0)
printf("4\n");
else
printf("0\n");
}
return 0;
}