【HDOJ】1061 Rightmost Digit
这道题目可以手工打表,也可以机器打表,千万不能暴力解,会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的更多相关文章
- HDU 1061 Rightmost Digit --- 快速幂取模
HDU 1061 题目大意:给定数字n(1<=n<=1,000,000,000),求n^n%10的结果 解题思路:首先n可以很大,直接累积n^n再求模肯定是不可取的, 因为会超出数据范围, ...
- hdoj 1061 Rightmost Digit【快速幂求模】
Rightmost Digit Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)T ...
- HDOJ 1061 Rightmost Digit(循环问题)
Problem Description Given a positive integer N, you should output the most right digit of N^N. Input ...
- HDOJ 1061 Rightmost Digit
找出数学规律 原题: Rightmost Digit Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Ja ...
- 杭电 1061 Rightmost Digit计算N^N次方的最后一位
Problem Description Given a positive integer N, you should output the most right digit of N^N. Input ...
- 题解报告:hdu 1061 Rightmost Digit(快速幂取模)
Problem Description Given a positive integer N, you should output the most right digit of N^N. Input ...
- 快速幂 HDU 1061 Rightmost Digit *
Rightmost Digit Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)T ...
- 【HDOJ】1597 find the nth digit
二分. #include <stdio.h> #include <math.h> int main() { int case_n; double n, tmp, l, r; i ...
- 【HDOJ】4729 An Easy Problem for Elfness
其实是求树上的路径间的数据第K大的题目.果断主席树 + LCA.初始流量是这条路径上的最小值.若a<=b,显然直接为s->t建立pipe可以使流量最优:否则,对[0, 10**4]二分得到 ...
随机推荐
- Sublime Text3一些安装和使用技巧
ST3是一款很好的编辑软件,他不仅仅是能编辑前端代码,包括JS,PHP,HTML,CSS等,还能编辑JAVA,C++等常用后代编辑语言.因为本人写前端,本篇文章只介绍ST3的一些前端的技巧. 对于ST ...
- C++重写与重载、重定义
文章引用自:http://blog.163.com/clevertanglei900@126/blog/static/111352259201102441934870/ 重载overload:是函数名 ...
- FileInputStream 与 BufferedInputStream 效率对比
我的技术博客经常被流氓网站恶意爬取转载.请移步原文:http://www.cnblogs.com/hamhog/p/3550158.html ,享受整齐的排版.有效的链接.正确的代码缩进.更好的阅读体 ...
- [Guava官方文档翻译] 1.Guava简介 (Introduction)
用户指南 Guava包含Google在Java项目中用到的一些核心库:collections, caching, primitives support, concurrency 库, common a ...
- 在Windows下用Mingw 4.5.2编译X264
1.下载mingw-get-inst-20110530.rar(http://www.baidu.com/link?url=-ixXW6QiuEl8CA1dKudoWCxzcTvxrpQ0nXRBHU ...
- OpenJudge/Poj 1723 SOLDIERS
1.链接地址: http://bailian.openjudge.cn/practice/1723/ http://poj.org/problem?id=1723 2.题目: 总时间限制: 1000m ...
- java.lang.StringBuilder源码分析
StringBuilder是一个可变序列的字符数组对象,它继承自AbstractStringBuilder抽象类.它不保证同步,设计出来的目的是当这个字符串缓存只有单线程使用的时候,取代StringB ...
- 深度模拟java动态代理实现机制系类之二
这次我们要实现的是对任意接口,任意的方法进行特定的代理 这里不一样的只有Proxy类,要实现对所有方法进行代理,那么重点就在于获得接口的所有方法 import java.io.File; import ...
- php 调用 webservice服务
class data{ $a = 123; $b = 456; } //直接php的SoapClient类 $client = new SoapClient('http://xxx.com/xx.as ...
- SSH+Ajax实现用户名重复检查(一)
1.struts.xml设置 <package name="default" namespace="/" extends="json-defau ...