51Nod-1004-n^n的末位数字
2016-05-17 21:08
337 查看
给出一个整数N,输出N^N(N的N次方)的十进制表示的末位数字。
Input
一个数N(1 <= N <= 10^9)
Output
输出N^N的末位数字
Input示例
13
Output示例
3
一道规律题,幂的末位数的规律为四次一循环,所以……
Input
一个数N(1 <= N <= 10^9)
Output
输出N^N的末位数字
Input示例
13
Output示例
3
一道规律题,幂的末位数的规律为四次一循环,所以……
#include <stdio.h> #include <math.h> int main() { int a, b, c; scanf("%d", &a); b = a % 10; //幂的末尾数字规律为4个一循环 c = a % 4; //c等于0时为第四个 if (c == 0) c = 4; c = pow(b, c); printf("%d", c % 10); return 0; }
相关文章推荐
- http post 请求数据格式选择
- 最大流-POJ-1459-Power Network
- 数据库--ORCAL--day01
- Ubuntu、Windows 、Linux集合
- Linux mysql 5.6: ERROR 1045 (28000): Access denied for user 'root'@'localhost' (usin
- C++ vector用法
- 二叉树的镜像——19
- hrbust/哈理工oj 1867 小伙伴的数据结构【树状数组】
- leetcode_ Bulls and Cows
- Codeforces Round #353 (Div. 2)C. Money Transfers
- HDU 5074 Hatsune Miku(DP)
- CodeForces 608B Hamming Distance Sum
- PAT - 肿瘤诊断 - 三维简单广搜
- 菜单栏垂直导航
- CentOS yum 源的配置与使用
- MIT 6.828 JOS学习笔记18. Lab 3.2 Part B: Page Faults, Breakpoints Exceptions, and System Calls
- Android——计算器
- Connection.setAutoCommit使用的注意事项
- Handler源码分析
- UVa10129 Play on Words 并查集判断连通+欧拉通路