HDU 1061 JAVA
来源:互联网 发布:android 7.0 源码目录 编辑:程序博客网 时间:2024/06/05 00:35
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
2
3
4
Sample Output
7
6
package hlh;import java.util.Scanner;public class p1061 { // 用来找规律: 1~10:1 4 7 6 5 6 3 6 9 0 // 用来找规律: 11~20:1 6 3 6 5 6 7 4 9 0 // 用来找规律: 21~30:1 4 7 6 5 6 3 6 9 0 // 用来找规律: 31~40:1 6 3 6 5 6 7 4 9 0 public static void main(String[] args) { /* for(int x=111;x<=120;x++){ int temp = x%10; for(int i=1;i<x;i++){ temp = (temp*x%10)%10; } System.out.print(temp+" "); }*/ Scanner sc = new Scanner(System.in); int t=sc.nextInt(); while(t-->0){ int a [] = {1,4,7,6,5,6,3,6,9,0,1,6,3,6,5,6,7,4,9,0}; int x =sc.nextInt(); x = x%20; if(x%10==0){ System.out.println(0); continue; } System.out.println(a[x-1]); } }}
0 0
- HDU 1061 JAVA
- hdu acm hdu 2115 Java
- Exponentiation hdu 1063 java
- hdu 1313 (Java)
- 【Java】hdu 4043
- hdu 1242 Rescue<java>
- HDU 1002 JAVA
- hdu 2092(java)
- hdu 1063 java 高精度
- hdu 1106(java)
- hdu 1073(java)
- HDU-4762 Java高精度
- hdu 1002 java
- hdu 1089 java
- JAVA hdu 2192 MagicBuilding
- hdu 1001 java
- hdu 1002 java
- hdu 1003 java
- 爬山算法
- [日志处理]log4j配置详解
- ISO Latin-1字符集
- [Emacs]配置
- 高并发下的秒杀、抢东西
- HDU 1061 JAVA
- 关于mysql中对数据先统计再排序的操作
- yourphp_v2.2使用问题处理
- jfinal介绍
- wait,notify,notifyAll详细介绍
- iOS中的沙盒机制
- Redis五种数据类型介绍
- Redis事务介绍
- TCP/IP深入浅出-写的太好了