hdu 1061 Rightmost Digit
2015-10-08 15:09
393 查看
Problem Description
Given a positive integer N, you should output the most right digit of N^N.
Input
The input contains several test cases. The first line of the input is a single integer T which is the number of test cases. T test cases follow.
Each test case contains a single positive integer N(1<=N<=1,000,000,000).
Output
For each test case, you should output the rightmost digit of N^N.
Sample Input
Sample Output
以4为循环
Given a positive integer N, you should output the most right digit of N^N.
Input
The input contains several test cases. The first line of the input is a single integer T which is the number of test cases. T test cases follow.
Each test case contains a single positive integer N(1<=N<=1,000,000,000).
Output
For each test case, you should output the rightmost digit of N^N.
Sample Input
2 3 4
Sample Output
7 6 Hint In the first case, 3 * 3 * 3 = 27, so the rightmost digit is 7. In the second case, 4 * 4 * 4 * 4 = 256, so the rightmost digit is 6.
以4为循环
#include <stdio.h> int main() { int a[10][4]={ 0,0,0,0, 1,1,1,1, 6,2,4,8, 1,3,9,7, 6,4,6,4, 5,5,5,5, 6,6,6,6, 1,7,9,3, 6,8,4,2, 1,9,1,9}; int n,t; scanf("%d",&t); while(t--) { scanf("%d",&n); printf("%d\n",a[n%10][n%4]); } return 0; }
相关文章推荐
- 算法导论12.4随机构建二叉搜索树 练习总结
- arc和mrc混用
- ios开发——日常之在Xcode6 后如何创建类目和延展(category&extension&protocol)
- .net在linux下部署项目
- qt入门小程序
- 数据输入控件使用简介
- iOS开发--点击屏幕获得屏幕坐标
- Sichuan Province 2012 F Fold The Paper
- stm8 io口 spi模拟,可用于RC522
- 面试题151-175
- 如何将APP安装包发布到360手机助手上
- C# 自定义拓展方法(this修饰符)
- iOS﹣ Autolayout NSLayoutConstraint
- 深入理解Android之Gradle
- css透明度
- 关于 iOS 中两个时间实现联动的解决方案
- javascript之,深扒typeof,instanceof操作符
- 黑马程序员---OC学习笔记之block访问外部变量【重点面试】
- 关于链表的一些总结和代码,java实现
- 构成vspher虚拟化平台所需构建概念