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.

Sample Input

Input
4
Output
4
Input
124356983594583453458888889
Output
0

Hint

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

Note to the first sample:

题意:  给你N  让你求 (1n + 2n + 3n + 4nmod 5

题解:  打个表 发现了规律

#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <algorithm>
#include <queue>
#include<vector>
#include <map>
using namespace std ;
typedef long long ll; const int N=+;
const int maxn = ; char s[maxn];
int main()
{
scanf("%s",s);
int len=strlen(s);
int a=s[len-]-'';
int b=s[len-]-'';
int c=a+b*;
if(c%==)
printf("4\n");
else
printf("0\n");
return ;
}

代码

Codeforces 456B Fedya and Maths 打表找规律的更多相关文章

  1. Tetrahedron(Codeforces Round #113 (Div. 2) + 打表找规律 + dp计数)

    题目链接: https://codeforces.com/contest/166/problem/E 题目: 题意: 给你一个三菱锥,初始时你在D点,然后你每次可以往相邻的顶点移动,问你第n步回到D点 ...

  2. Codeforces 193E - Fibonacci Number(打表找规律+乱搞)

    Codeforces 题目传送门 & 洛谷题目传送门 蠢蠢的我竟然第一眼想套通项公式?然鹅显然 \(5\) 在 \(\bmod 10^{13}\) 意义下并没有二次剩余--我真是活回去了... ...

  3. Codeforces 998D. Roman Digits 【打表找规律】

    <题目链接> 题目大意: 现在有无限个 1,5,10,50这四个数字,从中恰好挑选n个数字,问你这些数字的和总共有多少种不同的情况. 解题分析: 由于此题 n 的范围特别大,达到了1e9, ...

  4. CodeForces 768E Game of Stones 打表找规律

    题意: 在经典Nim博弈的基础上增加了新的限制:如果从这堆石子中移走\(x\)个石子,那么之后就不能再从这堆移走\(x\)个. 分析: 因为之前的操作会对后面的转移有影响,所以在保存状态时还要记录哪些 ...

  5. codeforces#1090 D. New Year and the Permutation Concatenation(打表找规律)

    题意:给出一个n,生成n的所有全排列,将他们按顺序前后拼接在一起组成一个新的序列,问有多少个长度为n的连续的子序列和为(n+1)*n/2 题解:由于只有一个输入,第一感觉就是打表找规律,虽然表打出来了 ...

  6. Codeforces Round #493 (Div. 2)D. Roman Digits 第一道打表找规律题目

    D. Roman Digits time limit per test 1 second memory limit per test 256 megabytes input standard inpu ...

  7. Codeforces Beta Round #24 D. Broken robot (打表找规律)

    题目链接: 点击我打开链接 题目大意: 给你 \(n,j\),再给出 \(m[0]\) 的坐标和\(a[0]-a[n-1]\) 的坐标. 让你输出 \(m[j]\) 的坐标,其中 \(m[i]\) 和 ...

  8. hdu 3032 Nim or not Nim? (SG函数博弈+打表找规律)

    Nim or not Nim? Time Limit:1000MS     Memory Limit:32768KB     64bit IO Format:%I64d & %I64u Sub ...

  9. HDU 5753 Permutation Bo (推导 or 打表找规律)

    Permutation Bo 题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=5753 Description There are two sequen ...

随机推荐

  1. Laravel-查询作用域

    Laravel-查询作用域 标签(空格分隔): php, laravel 全局作用域 ## 编写全局作用域 ## 编写全局作用域很简单.定义一个实现 Illuminate\Database\Eloqu ...

  2. ps -aux ,ps aux ,ps -ef 的区别

    Linux中的ps命令是Process Status的缩写.ps命令用来列出系统中当前运行的那些进程.ps命令列出的是当前那些进程的快照,就是执行ps命令的那个时刻的那些进程,如果想要动态的显示进程信 ...

  3. OpenCascade 边界表示法(BRep)

    转自 http://www.cppblog.com/eryar/archive/2013/08/20/202678.html Topology and Geometry in OpenCascade- ...

  4. 《剑指offer 第二版》题解

    剑指Offer 按题号排序 面试题 3:数组中重复的数字 面试题 4:二维数组中的查找 面试题 5:替换空格 面试题 6:从头到尾打印链表 面试题 7:重建二叉树 面试题 8:二叉树的下一个节点 面试 ...

  5. SDL2源代码分析

    1:初始化(SDL_Init()) SDL简介 有关SDL的简介在<最简单的视音频播放示例7:SDL2播放RGB/YUV>以及<最简单的视音频播放示例9:SDL2播放PCM>中 ...

  6. Java中 ArrayList类的使用

    java.util.ArrayList 是大小可变的数组的实现,存储在内的数据称为元素.此类提供一些方法来操作内部存储 的元素. ArrayList 中可不断添加元素,其大小也自动增长. ArrayL ...

  7. 路飞学城Python-Day107

    88-Ajax简介 Ajax是前端的JS技术,目前向服务器发送请求是通过1.向浏览器的地址栏发送请求的方式:2.form表单的请求方式是两种get和post方式:3.a标签的href属性对接地址 是一 ...

  8. postman测试实例--断言

    postman测试实例--断言 让我们来看看postman测试的一些例子. 其中大部分是作为内部postman片段. 大多数测试是为单行的JavaScript语句一样简单. 只要你想一个请求,你可以有 ...

  9. C语言基础 (6) 类型转换,数组与随机数

    复习 1.隐式转换 Double a Int b = 1 A = b //编译器自动转换把b转换为double类型后 再给a赋值(隐式转换) 2.强制类型转换 (变量)类型名 Int a = 1 // ...

  10. JZOJ5804. 【2018.08.12提高A组模拟】简单的序列

    性质:每个位置的前缀和必须大于0,总和=0.以此dp即可. #include <iostream> #include <cstdio> #include <cstring ...