这道题就是HDOJ的1061的变形:

1061 :求n的n次方的个位数 http://www.cnblogs.com/xiezie/p/5596779.html

1097 :求n的m次方的个位数

因此,就不在这里赘述了

以下是JAVA实现:

import java.io.BufferedInputStream;
import java.util.ArrayList;
import java.util.Scanner; public class Main { public static void main(String[] args) {
Scanner scan = new Scanner(new BufferedInputStream(System.in));
while(scan.hasNext()){
int n = scan.nextInt();
int m = scan.nextInt();
int rightMostDigitOfN = n%10;
ArrayList<Integer> rightMostDigits = arrays.get(rightMostDigitOfN);
int size = rightMostDigits.size();
if(size == 1){
System.out.println(rightMostDigitOfN);
}else{
System.out.println(rightMostDigits.get((m-1)%size));
}
}
scan.close();
} static ArrayList<ArrayList<Integer>> arrays = getRightMostDigitArray(); static ArrayList<ArrayList<Integer>> getRightMostDigitArray(){
ArrayList<ArrayList<Integer>> arrays = new ArrayList<>();
for(int i = 0 ; i != 10 ; i ++){
ArrayList<Integer> integers = new ArrayList<>();
integers.add(i);
int n = 2;
while(true){
int rightMostDigit = (int) (Math.pow(i, n)%10);
if(rightMostDigit==i){
break;
}else{
integers.add(rightMostDigit);
}
n++;
}
arrays.add(integers);
}
return arrays;
} }

HDOJ-ACM1097(JAVA) A hard puzzle的更多相关文章

  1. hdoj 1753 (Java)

    刚刚开始用Java,代码难免不够简洁. import java.math.BigDecimal; import java.util.Scanner; public class Main { publi ...

  2. 【HDOJ】1097 A hard puzzle

    题目和1061非常相似,几乎可以复用. #include <stdio.h> ][]; int main() { int a, b; int i, j; ; i<; ++i) { b ...

  3. 【HDOJ】1098 Ignatius's puzzle

    数学归纳法,得证只需求得使18+ka被64整除的a.且a不超过65. #include <stdio.h> int main() { int i, j, k; while (scanf(& ...

  4. Spark案例分析

    一.需求:计算网页访问量前三名 import org.apache.spark.rdd.RDD import org.apache.spark.{SparkConf, SparkContext} /* ...

  5. HDOJ 1098 Ignatius's puzzle

    Problem Description Ignatius is poor at math,he falls across a puzzle problem,so he has no choice bu ...

  6. HDOJ 1097 A hard puzzle(循环问题)

    Problem Description lcy gives a hard puzzle to feng5166,lwg,JGShining and Ignatius: gave a and b,how ...

  7. HDOJ 5411 CRB and Puzzle 矩阵高速幂

    直接构造矩阵,最上面一行加一排1.高速幂计算矩阵的m次方,统计第一行的和 CRB and Puzzle Time Limit: 2000/1000 MS (Java/Others)    Memory ...

  8. one recursive approach for 3, hdu 1016 (with an improved version) , permutations, N-Queens puzzle 分类: hdoj 2015-07-19 16:49 86人阅读 评论(0) 收藏

    one recursive approach to solve hdu 1016, list all permutations, solve N-Queens puzzle. reference: t ...

  9. 【HDOJ】1857 Word Puzzle

    trie树.以puzzle做trie树内存不够,从puzzle中直接找串应该会TLE.其实可以将查询组成trie树,离线做.扫描puzzle时注意仅三个方向即可. /* 1857 */ #includ ...

随机推荐

  1. 谈谈GUI的配色和字体选择

    对于工控领域的显示屏,显示效果很难和电脑屏幕相比.电脑上操作系统或者各种软件的配色方案,在应用到工业控制屏上就会出现“完全不是所想要”的结果,所以工控领域GUI的色彩.字体的选择还是有特别的讲究. 配 ...

  2. CODEVS 1638 修复公路

    题目描述 Description A地区在地震过后,连接所有村庄的公路都造成了损坏而无法通车.政府派人修复这些公路. 给出A地区的村庄数N,和公路数M,公路是双向的.并告诉你每条公路的连着哪两个村庄, ...

  3. 代码审查工具 StyleCop 的探索

    最近我们Advent Data Service (ADS) 在项目上需要按照代码规范进行代码的编写工作,以方便将来代码的阅读与维护. 但是人工检查起来容易遗漏或者格式不统一, ReSharper又是收 ...

  4. PPTPD/L2TP/IPSec VPN一键安装包 For CentOS 6

    一.一键安装PPTPD VPN 本教程适用于Openv VPS.Xen VPS或者KVM VPS. 1.首先运行如下命令: cat /dev/net/tun 返回的必须是: cat: /dev/net ...

  5. Hadoop 2.4.0完全分布式平台搭建、配置、安装

    一:系统安装与配置 Hadoop选择下载2.4.0 http://hadoop.apache.org / http://mirror.bit.edu.cn/apache/hadoop/common/h ...

  6. CSS 背景-CSS background

    这里有个很好的样式学习网站:http://www.divcss5.com/rumen/r125.shtml 一.Css background背景语法   -   TOP CSS背景基础知识 CSS 背 ...

  7. MySQL db优化

    http://blog.csdn.net/likika2012/article/details/38816037 http://www.nowamagic.net/librarys/veda/deta ...

  8. HDOJ多校联合第五场

    1001 Inversion 题意:求逆序对,然后交换k次相邻的两个数,使得剩下的逆序对最少. 分析:题目用到的结论是:数组中存在一对逆序对,那么可以通过交换相邻两个数使得逆序对减少1,交换k次,可以 ...

  9. ANDROID_MARS学习笔记_S02_002_Date\TimePicker

    一.文档用法 1.xml <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" ...

  10. Show username instead of "System Account" in SharePoint 2010

    Problems: When I load my local SharePoint site, the account always show as "System Account" ...