这道题目可以手工打表,也可以机器打表,千万不能暴力解,会TLE。

 #include <stdio.h>

 #define MAXNUM 1000000001

 int buf[][];

 int main() {
int case_n, n;
int i, j; for (i=; i<; ++i) {
buf[i][] = ;
buf[i][] = i;
for (j=; j<; ++j) {
buf[i][j] = buf[i][j-]*i%;
if (buf[i][j] == buf[i][])
break;
buf[i][]++;
}
}
/*
for (i=0; i<10; ++i) {
printf("%d:", i);
for (j=1; j<=buf[i][0]; ++j)
printf(" %d", buf[i][j]);
printf("\n");
}
*/
scanf("%d", &case_n); while (case_n--) {
scanf("%d", &n);
i = n % ;
j = n % buf[i][];
if (!j)
j = buf[i][];
printf("%d\n", buf[i][j]);
} return ;
}

【HDOJ】1061 Rightmost Digit的更多相关文章

  1. HDU 1061 Rightmost Digit --- 快速幂取模

    HDU 1061 题目大意:给定数字n(1<=n<=1,000,000,000),求n^n%10的结果 解题思路:首先n可以很大,直接累积n^n再求模肯定是不可取的, 因为会超出数据范围, ...

  2. hdoj 1061 Rightmost Digit【快速幂求模】

    Rightmost Digit Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)T ...

  3. HDOJ 1061 Rightmost Digit(循环问题)

    Problem Description Given a positive integer N, you should output the most right digit of N^N. Input ...

  4. HDOJ 1061 Rightmost Digit

    找出数学规律 原题: Rightmost Digit Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Ja ...

  5. 杭电 1061 Rightmost Digit计算N^N次方的最后一位

    Problem Description Given a positive integer N, you should output the most right digit of N^N. Input ...

  6. 题解报告:hdu 1061 Rightmost Digit(快速幂取模)

    Problem Description Given a positive integer N, you should output the most right digit of N^N. Input ...

  7. 快速幂 HDU 1061 Rightmost Digit *

    Rightmost Digit Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)T ...

  8. 【HDOJ】1597 find the nth digit

    二分. #include <stdio.h> #include <math.h> int main() { int case_n; double n, tmp, l, r; i ...

  9. 【HDOJ】4729 An Easy Problem for Elfness

    其实是求树上的路径间的数据第K大的题目.果断主席树 + LCA.初始流量是这条路径上的最小值.若a<=b,显然直接为s->t建立pipe可以使流量最优:否则,对[0, 10**4]二分得到 ...

随机推荐

  1. selenium2.0处理case实例(二)

    本文通过具体代码处理过程, 来展示selenium中一些比较不常用的类的用法 1.javascriptExcutor,通过将driver强转成JavascriptExecutor类型, 调用execu ...

  2. Android系统简介(中):系统架构

    Android的系统架构栈分为4层,从上往下分别是Applications.Application framework.Libraries  & Android Runtime.Linux  ...

  3. 2016/01/19 javascript学习笔记-name属性

    1. name属性只在少数html元素中有效:包括表单.表单元素.<iframe>和<img>元素. 基于name属性的值选取html元素,可以使用document对象的get ...

  4. [Guava官方文档翻译] 3. 前置条件检查(Preconditions Explained)

    本文地址:http://www.cnblogs.com/hamhog/p/3536964.html 前置条件检查 Guava提供了一些检查前置条件的utilities.我们强烈建议静态import这些 ...

  5. 第48条:如果需要精确的答案,请避免使用float和double

    float和double主要为了科学计算和工程计算而设计,执行二进制浮点运算,这是为了在广泛的数值范围上提供较为精确的快速近似计算而精心设计的.然而,它们没有提供完全精确的结果,所以不适合用于需要精确 ...

  6. linq递归

    public class Comment { public int Id { get; set; } public int ParentId { get; set; } public string T ...

  7. apply()与call()的区别

    一直都没太明白apply()与call()的具体使用原理,今日闲来无事,决定好好研究一番. JavaScript中的每一个Function对象都有一个apply()方法和一个call()方法,它们的语 ...

  8. js之replace实现简单模板替换引擎

    eg: var app={}; app.tempEngine= (function () {  var pattern = /\{(\w*[:]*[=]*\w+)\}(?!})/g;  return ...

  9. 关于.NET技术前途问题的讨论

    我去年曾经在论坛发起过关于.NET技术前途问题这个话题的讨论,也引起了很多同行和朋友的回复,时间过去大半年,自己也有了一些新的理解.本文的目的就是将其中一些精彩的观点整理出来并谈谈自己的观点. 引子 ...

  10. 在网页中插入qq连接

    <a href="tencent://message/?uin=这里写qq号 &Site=这里随便七个名字 &Menu=要为yes">显示出来的名字&l ...