CodeForces 742A Arpa’s hard exam and Mehrdad’s naive cheat
题意:求1378 n次幂的最后一位。
析:两种方法,第一种,就是快速幂,第二种找循环节,也很好找,求一下前几个数就好。
代码如下:
#pragma comment(linker, "/STACK:1024000000,1024000000")
#include <cstdio>
#include <string>
#include <cstdlib>
#include <cmath>
#include <iostream>
#include <cstring>
#include <set>
#include <queue>
#include <algorithm>
#include <vector>
#include <map>
#include <cctype>
#include <cmath>
#include <stack>
#define freopenr freopen("in.txt", "r", stdin)
#define freopenw freopen("out.txt", "w", stdout)
using namespace std; typedef long long LL;
typedef pair<int, int> P;
const int INF = 0x3f3f3f3f;
const double inf = 0x3f3f3f3f3f3f;
const double PI = acos(-1.0);
const double eps = 1e-8;
const int maxn = 1e5 + 5;
const int mod = 1e9 + 7;
const int dr[] = {-1, 1, 0, 0};
const int dc[] = {0, 0, 1, -1};
const char *de[] = {"0000", "0001", "0010", "0011", "0100", "0101", "0110", "0111", "1000", "1001", "1010", "1011", "1100", "1101", "1110", "1111"};
int n, m;
const int mon[] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
const int monn[] = {0, 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
inline int Min(int a, int b){ return a < b ? a : b; }
inline int Max(int a, int b){ return a > b ? a : b; }
inline LL Min(LL a, LL b){ return a < b ? a : b; }
inline LL Max(LL a, LL b){ return a > b ? a : b; }
inline bool is_in(int r, int c){
return r >= 0 && r < n && c >= 0 && c < m;
} int main(){
while(cin >> n){
if(!n) printf("1\n");
else {
n = n % 4;
if(1 == n) printf("8\n");
else if(2 == n) printf("4\n");
else if(3 == n) printf("2\n");
else if(0 == n) printf("6\n");
}
}
return 0;
}
CodeForces 742A Arpa’s hard exam and Mehrdad’s naive cheat的更多相关文章
- 【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 ...
- codeforces 741D Arpa’s letter-marked tree and Mehrdad’s Dokhtar-kosh paths(启发式合并)
codeforces 741D Arpa's letter-marked tree and Mehrdad's Dokhtar-kosh paths 题意 给出一棵树,每条边上有一个字符,字符集大小只 ...
- codeforces 741D Arpa’s letter-marked tree and Mehrdad’s Dokhtar-kosh paths
题目链接:Arpa’s letter-marked tree and Mehrdad’s Dokhtar-kosh paths 第一次写\(dsu\ on\ tree\),来记录一下 \(dsu\ o ...
- CodeForces - 851B -Arpa and an exam about geometry(计算几何)
Arpa is taking a geometry exam. Here is the last problem of the exam. You are given three points a, ...
- Codeforces 741B Arpa's weak amphitheater and Mehrdad's valuable Hoses
[题目链接] http://codeforces.com/problemset/problem/741/B [题目大意] 给出一张图,所有连通块构成分组,每个点有价值和代价, 要么选择整个连通块,要么 ...
- codeforces 742D Arpa's weak amphitheater and Mehrdad's valuable Hoses ——(01背包变形)
题意:给你若干个集合,每个集合内的物品要么选任意一个,要么所有都选,求最后在背包能容纳的范围下最大的价值. 分析:对于每个并查集,从上到下滚动维护即可,其实就是一个01背包= =. 代码如下: #in ...
- CodeForces 742B Arpa’s obvious problem and Mehrdad’s terrible solution (暴力枚举)
题意:求定 n 个数,求有多少对数满足,ai^bi = x. 析:暴力枚举就行,n的复杂度. 代码如下: #pragma comment(linker, "/STACK:1024000000 ...
- Codeforces 741B Arpa's weak amphitheater and Mehrdad's valuable Hoses (并查集+分组背包)
<题目链接> 题目大意: 就是有n个人,每个人都有一个体积和一个价值.这些人之间有有些人之间是朋友,所有具有朋友关系的人构成一组.现在要在这些组中至多选一个人或者这一组的人都选,在总容量为 ...
- Codeforces 741D Arpa’s letter-marked tree and Mehrdad’s Dokhtar-kosh paths(dsu on tree)
感觉dsu on tree一定程度上还是与点分类似的.考虑求出跨过每个点的最长满足要求的路径,再对子树内取max即可. 重排后可以变成回文串相当于出现奇数次的字母不超过1个.考虑dsu on tree ...
随机推荐
- ETL利器Kettle
ETL利器Kettle实战应用解析系列一[Kettle使用介绍] 本系列文章主要索引如下: 一.ETL利器Kettle实战应用解析系列一[Kettle使用介绍] 二.ETL利器Kettle实战应用解析 ...
- 为什么C#中应该用Try-Catch?
[为什么C#中应该用Try-Catch?] http://blog.csdn.net/dier4836/article/details/7292897
- css学习中的一些英文单词
indent 缩进 through通过 decoration装饰 position定位
- LDAP与Samba
默认的Samba服务器支持本地系统用户(smbpasswd添加后)访问Samba资源,不支持OpenLDAP服务器账号访问Samba共享资源 目的:配置完后,OpenLDAP每新增一个用户,就自动支持 ...
- oracle 表被锁定 杀死进程
/*查出被锁biao*/ select b.owner,b.object_name,a.session_id,a.locked_mode from v$locked_object a,dba_obje ...
- iOS开发中对RunLoop的个人心得
从接触iOS到现在也有将近两年了,对iOS中的RunLoop也有了一定的认识,下面讲讲个人对RunLoop的理解. 初识RunLoop RunLoops是与线程相关联的基础部分,一个Run Loo ...
- Hdu OJ 5965 扫雷(递推)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5965 题目大意:中文题,自己读 解图思路:对于每一列都有三种情况--0, 1, 2. 如果第一列确定地 ...
- 制作Nine-Patch图片的流程
1.找到draw9patch.bat文件,在Android sdk目录下的tools文件夹中. 2.双击打开draw9patch.bat文件,在导航栏点击File->Open 9-patch将图 ...
- redis 在linux下的安装
背景:在项目互联网项目开发中我们经常需要缓存热点数据,在做热点数据缓存时有2个常用的方案 redis简介redis是一个key-value存储系统.和Memcached类似,它支持存储的value类型 ...
- linux driver编译环境搭建和命令
首先将ubuntu14.04的内核升级到内核3.18.12. 其次,Ubuntu14.04上驱动编译命令 $ sudo make -C ~/linux-3.18.12/ M=`pwd` modules ...