Codeforces Round #260 (Div. 2) B

Description

Fedya studies in a gymnasium. Fedya's maths hometask is to calculate the following expression:

(1n + 2n + 3n + 4nmod 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).

Input

The single line contains a single integer n (0 ≤ n ≤ 10105). The number doesn't contain any leading zeroes.

Output

Print the value of the expression without leading zeros.

Examples
input
4
output
4
input
124356983594583453458888889
output
0
Note

Operation x mod y means taking remainder after division x by y.

Note to the first sample:

题意:看题目中的公式

解法:打表找规律

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#include<bits/stdc++.h>
using namespace std;
class P
{
    public:
    int n,m;
};
bool cmd(P x,P y)
{
    return x.n<y.n;
}
int main()
{
    long long ans=0;
    string s;
    cin>>s;
    if(s.length()==1)
    {
     ans+=s[s.length()-1]-'0';
    }
    else
    {
        ans+=((s[s.length()-2]-'0')*10+s[s.length()-1]-'0');
    }
  //  cout<<ans<<endl;
    if(ans%4)
    {
        cout<<"0"<<endl;
    }
    else
    {
        cout<<"4"<<endl;
    }
    return 0;
}

  

posted @   樱花落舞  阅读(199)  评论(0编辑  收藏  举报
编辑推荐:
· 从 HTTP 原因短语缺失研究 HTTP/2 和 HTTP/3 的设计差异
· AI与.NET技术实操系列:向量存储与相似性搜索在 .NET 中的实现
· 基于Microsoft.Extensions.AI核心库实现RAG应用
· Linux系列:如何用heaptrack跟踪.NET程序的非托管内存泄露
· 开发者必知的日志记录最佳实践
阅读排行:
· TypeScript + Deepseek 打造卜卦网站:技术与玄学的结合
· Manus的开源复刻OpenManus初探
· AI 智能体引爆开源社区「GitHub 热点速览」
· 从HTTP原因短语缺失研究HTTP/2和HTTP/3的设计差异
· 三行代码完成国际化适配,妙~啊~
点击右上角即可分享
微信分享提示