A. Arpa’s hard exam and Mehrdad’s naive cheat
time limit per test

1 second

memory limit per test

256 megabytes

input

standard input

output

standard output

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 1378n.

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 1378n.

Examples
input
1

output
8

input
2

output
4

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.

打表,成一个循环

#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <climits>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <vector>
#include <list>
#define rep(i,m,n) for(i=m;i<=n;i++)
#define rsp(it,s) for(set<int>::iterator it=s.begin();it!=s.end();it++)
const int inf_int = 2e9;
const long long inf_ll = 2e18;
#define inf_add 0x3f3f3f3f
#define mod 1000000007
#define vi vector<int>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define pi acos(-1.0)
#define pii pair<int,int>
#define Lson L, mid, rt<<1
#define Rson mid+1, R, rt<<1|1
const int maxn=5e2+10;
using namespace std;
typedef  long long ll;
typedef  unsigned long long  ull;
inline int read(){int ra,fh;char rx;rx=getchar(),ra=0,fh=1;
while((rx<'0'||rx>'9')&&rx!='-')rx=getchar();if(rx=='-')
fh=-1,rx=getchar();while(rx>='0'&&rx<='9')ra*=10,ra+=rx-48,
rx=getchar();return ra*fh;}
//#pragma comment(linker, "/STACK:102400000,102400000")
ll gcd(ll p,ll q){return q==0?p:gcd(q,p%q);}
ll qpow(ll p,ll q){ll f=1;while(q){if(q&1)f=f*p;p=p*p;q>>=1;}return f;}ll n;
int a[4]={6,8,4,2};
int main()
{cin >> n; if(n==0){cout << "1" <<endl; return 0;}cout << a[n%4]<<endl;return 0;
}

Codeforces 742A Arpa’s hard exam and Mehrdad’s naive cheat 打表+水题相关推荐

  1. 【codeforces 742A】Arpa’s hard exam and Mehrdad’s naive cheat

    time limit per test1 second memory limit per test256 megabytes inputstandard input outputstandard ou ...

  2. codeforces 742A-Arpa’s hard exam and Mehrdad’s naive cheat 快速幂

    传送门 : CF 742A 题解 直接做8的快速幂, 因为模数是10 用周期做也可以, 不过我优化不到0ms- AC code /*adrui's submissionLanguage : C++Re ...

  3. Codeforces 742B Arpa’s obvious problem and Mehrdad’s terrible solution

    http://codeforces.com/contest/742/problem/B B. Arpa's obvious problem and Mehrdad's terrible solutio ...

  4. 【CodeForces - 922B 】Magic Forest (数学,异或,暴力,水题,三元组问题)

    题干: Imp is in a magic forest, where xorangles grow (wut?) A xorangle of order n is such a non-degene ...

  5. 【CodeForces - 1051B】Relatively Prime Pairs (构造,思维,素数,水题)

    题干: You are given a set of all integers from ll to rr inclusive, l<rl<r, (r−l+1)≤3⋅105(r−l+1)≤ ...

  6. Codeforces Round #383 (Div. 2) D. Arpa's weak amphitheater and Mehrdad's valuable Hoses —— DP(01背包)

    题目链接:http://codeforces.com/contest/742/problem/D D. Arpa's weak amphitheater and Mehrdad's valuable ...

  7. Codeforces 741 D - Arpa’s letter-marked tree and Mehrdad’s Dokhtar-kosh paths

    D - Arpa's letter-marked tree and Mehrdad's Dokhtar-kosh paths 思路: 树上启发式合并 从根节点出发到每个位置的每个字符的奇偶性记为每个位 ...

  8. 【Codeforces 741 B. Arpa's weak amphitheater and Mehrdad's 】+ 并查集 + 01背包

    B. Arpa's weak amphitheater and Mehrdad's valuable Hoses time limit per test 1 second memory limit p ...

  9. Codeforces 742B B. Arpa’s obvious problem and Mehrdad’s terrible solution

    B. Arpa's obvious problem and Mehrdad's terrible solution time limit per test 1 second memory limit ...

最新文章

  1. oracle aul 索引,ORACLE恢復神器之ODU/AUL/DUL
  2. 计算机视觉面试常见问题(含解答)
  3. linux comm 12,Linux comm命令
  4. Android 解析AsyncTask(一)
  5. java assetmanager_AssetManager asset的使用
  6. 用ARM DS-5进行android linux开发
  7. disruptor入门
  8. 微软将开放神经网络交换格式贡献给 Linux 基金会
  9. Python time strftime() 方法
  10. python中整型_实例介绍Python中整型
  11. 元数据驱动设计 —— 设计一套用于API数据检索的灵活引擎
  12. 借助创客匠人玩转视频号
  13. 笔记本电脑连不上windows无线服务器,笔记本电脑连不上无线如何解决
  14. 管家婆打印报错——进程无法访问
  15. ant design pro 异步请求后台接口
  16. 深度神经网络——中文语音识别
  17. velodyne16驱动调试记录
  18. oracle数据库报错:ORA-01654: 索引 XXX 无法通过 128 (在表空间 xxx 中) 扩展
  19. 冯诺依曼计算机体系结构
  20. HTML身份证号校验及根据身份证号获取出生日期/性别

热门文章

  1. 关于浏览器运行原理的初步认知
  2. 2小时5台3389肉鸡,国人网络安全意思真差
  3. 探究核心技术最佳实践,云原生OLAP论坛火热开启!
  4. 视频转换与数字视频基础笔记
  5. Glide作为图片缓存,清除缓存的合理方法
  6. 普林斯顿研究者:当大公司控制了CS顶会的资金,坏处在哪?
  7. 【python】详解事件驱动event实现
  8. 计算机学院迎新晚会实施方案,“计青春”计算机学院XX迎新晚会活动策划 修订.pdf...
  9. DAX Calculate实战:如何帮助HR妹子整理考勤表
  10. ipcfg报错_静态局部变量和静态全程变量static。