E-COM-NET
首页
在线工具
Layui镜像站
SUI文档
联系我们
推荐频道
Java
PHP
C++
C
C#
Python
Ruby
go语言
Scala
Servlet
Vue
MySQL
NoSQL
Redis
CSS
Oracle
SQL Server
DB2
HBase
Http
HTML5
Spring
Ajax
Jquery
JavaScript
Json
XML
NodeJs
mybatis
Hibernate
算法
设计模式
shell
数据结构
大数据
JS
消息中间件
正则表达式
Tomcat
SQL
Nginx
Shiro
Maven
Linux
Rightmost
hdu_1061_
Rightmost
Digit
求n^n最右边的一位 找出规律即可 View Code #include<iostream> using namespace std; int main() { int T,n,ans,t; cin>>T; while(T--) { cin>>n; t=n%10;
·
2015-11-03 21:55
right
hdu 1061
Rightmost
Digit
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1061 题目大意:n的n次方,输入个位数~ 这里介绍一个小的算法:快速幂取模 首先,有n个数相乘,如s=a*a*a*a*a*a*a*a*a;假设b=a*a;则s=b*b*b*b*a;继续假设c=b*b;则s=c*c*a;继续假设d=c*c;则s=d*a;最后输出s。节省了时间。 1 #
·
2015-11-02 14:02
right
Rightmost
Digit
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 i
·
2015-11-02 10:29
right
HDU 1061
Rightmost
Digit
这道题看起来很吓人,数据量也很大,其实是有技巧的,最后一位就是N对10取模以后的N次方的最后一位,有10中可能,即从0到9,而观察可以发现,0到9这10个数不断的与自己相乘,最后一位是有周期的,下面的就很简单了 #include<iostream> using namespace std; long long N; int main() { int T; cin>&g
·
2015-10-31 13:00
right
HDOJ---1061
Rightmost
Digit[简单数学题]
Rightmost
Digit Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768
·
2015-10-31 10:26
right
HDU 1061
Rightmost
Digit
快速幂。只保存末位。快速幂的第一个题。 #include<cstdio> #include<cstring> #include<cmath> #include<algorithm> using namespace std; int main() { int T; scanf("%d",&am
·
2015-10-31 09:30
right
Rightmost
Digit(快速幂+数学知识OR位运算) 分类: 数学 2015-07-03 14:56 4人阅读 评论(0) 收藏
C -
Rightmost
Digit Time Limit:1000MS Memory Limit:32768KB 64bit IO Format:%I64d & %I64u Submit
·
2015-10-28 08:00
right
HDU 1061
Rightmost
Digit(快速幂)
Description给出一正整数n,输出n^n的个位Input第一行为用例组数T,每组用例占一行为一整数nOutput对每组用例,输出n^n的个位SampleInput234SampleOutput76Solution相当于求n^n(mod10),用快速幂即可Code#include #include usingnamespacestd; typedeflonglongll; llmod_pow
V5ZSQ
·
2015-09-04 08:00
HDU 1061.
Rightmost
Digit【数论及方法】【8月30】
RightmostDigitProblemDescriptionGivenapositiveintegerN,youshouldoutputthemostrightdigitofN^N. InputTheinputcontainsseveraltestcases.ThefirstlineoftheinputisasingleintegerTwhichisthenumberoftestcases.T
a995549572
·
2015-08-30 13:00
C++
ACM
HDU
hdu 1061
Rightmost
Digit
暴力解决不了问题,有规律可循,只需看末尾数字即可,末尾数字的n次方是有规律的 #include usingnamespacestd;intmain(){intn;intt;while(scanf("%d",&t)!=EOF){while(t--){ scanf("%d",&n);if(n%10==0)printf("0\n");elseif(n%10==1)printf("1\n");e
efine_dxq
·
2015-08-21 08:00
数论
C语言
ACM
HDU
找规律
HDU 1061
Rightmost
Digit(简单快速幂)
http://acm.hdu.edu.cn/showproblem.php?pid=1061RightmostDigitTimeLimit:2000/1000MS(Java/Others) MemoryLimit:65536/32768K(Java/Others)TotalSubmission(s):39858 AcceptedSubmission(s):15045ProblemDes
hellohelloC
·
2015-08-16 17:00
HDU 1061
Rightmost
Digit
链接:http://acm.hdu.edu.cn/showproblem.php?pid=1061RightmostDigitTimeLimit:2000/1000MS(Java/Others) MemoryLimit:65536/32768K(Java/Others)TotalSubmission(s):39835 AcceptedSubmission(s):15036Problem
Silenceneo
·
2015-08-15 18:00
HDU
快速幂
hdu 1061
Rightmost
Digit
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1061解题思路:快速幂。。。AC代码:#include #include usingnamespacestd; intmain(){ intT; scanf("%d",&T); while(T--){ intn; scanf("%d",&n); inttmp=n%10; intsum=1; while(
piaocoder
·
2015-08-07 22:00
快速幂
杭电1061
Rightmost
Digit
GivenapositiveintegerN,youshouldoutputthemostrightdigitofN^N.InputTheinputcontainsseveraltestcases.ThefirstlineoftheinputisasingleintegerTwhichisthenumberoftestcases.Ttestcasesfollow.Eachtestcaseconta
Scarlett_geng
·
2015-08-07 13:00
杭电
找规律
hdu 1061
Rightmost
Digit 快速幂
#include #include #include usingnamespacestd; intpow_mod(__int64a,__int64n,intm) { if(n==0)return1; __int64x=pow_mod(a,n/2,m); __int64ans=(x%m)*(x%m); if(n%2==1)ans=ans*a%m; return(int)ans; } intmain
xinag578
·
2015-08-06 09:00
HDU 1061
Rightmost
Digit
ProblemDescriptionGivenapositiveintegerN,youshouldoutputthemostrightdigitofN^N.InputTheinputcontainsseveraltestcases.ThefirstlineoftheinputisasingleintegerTwhichisthenumberoftestcases.Ttestcasesfollow
jtjy568805874
·
2015-07-18 22:00
HDU
HDU 1061
Rightmost
Digit (快速幂取余)
RightmostDigitTimeLimit:2000/1000MS(Java/Others) MemoryLimit:65536/32768K(Java/Others)TotalSubmission(s):38903 AcceptedSubmission(s):14660ProblemDescriptionGivenapositiveintegerN,youshouldoutput
qq_24653023
·
2015-07-10 16:00
ACM
HDU
hduoj
Rightmost
Digit
RightmostDigitTimeLimit:2000/1000MS(Java/Others)MemoryLimit:65536/32768K(Java/Others)TotalSubmission(s):7211AcceptedSubmission(s):1858 ProblemDescriptionGivenapositiveintegerN,youshouldoutputthemostri
lv414333532
·
2015-06-15 14:00
HDOJ 1061
Rightmost
Digit(快速幂求模)
RightmostDigitTimeLimit:2000/1000MS(Java/Others) MemoryLimit:65536/32768K(Java/Others)TotalSubmission(s):38422 AcceptedSubmission(s):14473ProblemDescriptionGivenapositiveintegerN,youshouldoutput
zwj1452267376
·
2015-05-27 18:00
HDU
Rightmost
Digit
RightmostDigitTimeLimit:2000/1000ms(Java/Other) MemoryLimit:65536/32768K(Java/Other)TotalSubmission(s):87 AcceptedSubmission(s):38Font:TimesNewRoman|Verdana|GeorgiaFontSize:←→ProblemDescriptionGiv
zp___waj
·
2015-05-27 08:00
HDU 3518 Boring counting 后缀自动机
求其中本质不同的子串的数量,这些子串满足在字符串S中出现了至少不重合的2次大致思路:如果将S建立后缀自动机的话,记录每个节点处的串最早一次和最后一次出现的位置,然后状态t处的字符串长度为[Min(t),Max(t)]比较其和
rightmost
-leftmost
u013738743
·
2015-05-05 09:00
HDU
后缀自动机
Counting
boring
3518
hdu oj 1061
Rightmost
Digit (快速幂算法)
这里首先要讲解一下快速幂算法:快速幂取模算法在网站上一直没有找到有关于快速幂算法的一个详细的描述和解释,这里,我给出快速幂算法的完整解释,用的是C语言,不同语言的读者只好换个位啦,毕竟读C的人较多~所谓的快速幂,实际上是快速幂取模的缩写,简单的说,就是快速的求一个幂式的模(余)。在程序设计过程中,经常要去求一些大数对于某个数的余数,为了得到更快、计算范围更大的算法,产生了快速幂取模算法。[有读者反
u014253173
·
2015-01-17 10:00
算法
ACM
HDU
OJ
快速幂算法
Rightmost
Digit
RightmostDigitTimeLimit:2000/1000MS(Java/Others)MemoryLimit:65536/32768K(Java/Others)TotalSubmission(s):35128AcceptedSubmission(s):13337ProblemDescriptionGivenapositiveintegerN,youshouldoutputthemostr
zchlww
·
2015-01-13 09:00
数据
printf
测试
HDU - 1061 -
Rightmost
Digit (快速幂取模!)
RightmostDigitTimeLimit:2000/1000MS(Java/Others) MemoryLimit:65536/32768K(Java/Others)TotalSubmission(s):34329 AcceptedSubmission(s):13091ProblemDescriptionGivenapositiveintegerN,youshouldoutput
u014355480
·
2014-12-14 09:00
Algorithm
C++
ACM
HDU
快速幂取模
HDU - 1061
Rightmost
Digit(数学)
题目大意:要你求出N^N结果的个位数。解析:找规律2^1=2,2^2=4,2^3=8,2^4=16,2^5=32,2^6=64......3^1=3,3^2=9,3^3=27,3^4=813^5=243......由上面可以得出一个规律,就是幂的个位数,是以4为周期的。所以要运算时要把n对4取余数,最后运算完再把结果对10取余数。注意:longlong要改为__int64#include #inc
HelloWorld10086
·
2014-11-02 15:00
HDU
digit
1061
Rightmost
HDU_ACM step 1.2.2
Rightmost
Digit (解法:快速幂取余和快速幂取余的推导过程)
版权所有,欢迎转载,转载请注明出处,谢谢RightmostDigitTimeLimit:2000/1000MS(Java/Others)MemoryLimit:65536/32768K(Java/Others)TotalSubmission(s):6293AcceptedSubmission(s):1645 ProblemDescriptionGivenapositiveintegerN,yous
keyyuanxin
·
2014-11-01 13:00
Algorithm
算法
ACM
快速幂取余
HDU 1061
Rightmost
Digit
分析:求n^n的个位数字首先:(a*b)%c=(a%c)*(b%c)%c,所以我们要计算:(n%10)*(n%10)*......*(n%10)%10;由于题中 n 较大一个一个算的话TLE利用分治法,每次求n^(n/2)%10,类似二分查找如:a^29=(a^14)^2*a;代码:#include #include #include #include usingnamespacestd; int
Houheshuai
·
2014-10-30 13:00
HDU-1061-
Rightmost
Digit
RightmostDigitTimeLimit:2000/1000MS(Java/Others) MemoryLimit:65536/32768K(Java/Others)TotalSubmission(s):33177 AcceptedSubmission(s):12701ProblemDescriptionGivenapositiveintegerN,youshouldoutput
u014355480
·
2014-10-29 17:00
C++
C语言
水题
HDU1061
HDU1061_
Rightmost
Digit【快速幂取余】
RightmostDigitTimeLimit:2000/1000MS(Java/Others) MemoryLimit:65536/32768K(Java/Others)TotalSubmission(s):33161 AcceptedSubmission(s):12696ProblemDescriptionGivenapositiveintegerN,youshouldoutputthem
u011676797
·
2014-10-28 22:00
1410231608-hd-
Rightmost
Digit
RightmostDigitTimeLimit:2000/1000MS(Java/Others) MemoryLimit:65536/32768K(Java/Others)TotalSubmission(s):33040 AcceptedSubmission(s):12651ProblemDescriptionGivenapositiveintegerN,youshouldoutputth
wangluoershixiong
·
2014-10-23 17:00
hdu1061
Rightmost
Digit
RightmostDigitTimeLimit:2000/1000MS(Java/Others) MemoryLimit:65536/32768K(Java/Others)TotalSubmission(s):29900 AcceptedSubmission(s):11382ProblemDescriptionGivenapositiveintegerN,youshouldoutput
svtter
·
2014-10-17 23:00
编程
C++
c
算法
编程语言
HDU1061
Rightmost
Digit
题目大意:求n^n最右位上的数字。#include#include#includeusingnamespacestd;intmain(){ intn2[4]={6,2,4,8}; intn3[4]={1,3,9,7}; intn4[2]={6,4}; intn7[4]={1,7,9,3}; intn8[4]={6,8,4,2}; intn9[2]={1,9}; intt; whi
AC_Gibson
·
2014-09-10 14:00
Rightmost
Digit(求N^N的个位)
1、N个位为0,1,4,5,6,9时,N^N的个位分别为0,1,6,5,6,9。2、N个位为其他数字时,根据N的十位奇偶性,N^N的个位只有2种情况。#include usingnamespacestd; intmain(){ intN,T,N1,N2; cin>>T; while(T--){ cin>>N; N1=N%10; N2=N%100/10; switch(N1) { case0:co
sinat_17231979
·
2014-09-07 12:00
HDU1061-
Rightmost
Digit(快速幂取模)
题目链接题意:求n^n的个位数的值。思路:快速幂求值代码:#include #include #include #include #include usingnamespacestd; typedef__int64ll; //typedeflonglongll; constintMOD=1000000000; lln; llpow_mod(llk){ if(k==1) returnn%M
u011345461
·
2014-08-29 22:00
HDU - 1061
Rightmost
Digit
DescriptionGivenapositiveintegerN,youshouldoutputthemostrightdigitofN^N. InputTheinputcontainsseveraltestcases.ThefirstlineoftheinputisasingleintegerTwhichisthenumberoftestcases.Ttestcasesfollow.Eacht
u011345136
·
2014-07-28 18:00
LeetCode 41. Trapping Rain Water O(n)实现
参考了hackersun007的题解对于每个A[i],若它两边的最高高度满足min(leftmost[i],
rightmost
[i])>A[i],则坐标i上对应的水的横截面积为 min(leftmost
u014674776
·
2014-06-28 09:00
LeetCode
C++
LeetCode 9. Palindrome Number
代码:classSolution { public: boolisPalindrome(intx) { if(x0;copy/=10,
rightmost
*=10){} while(x!
u014674776
·
2014-06-08 03:00
LeetCode
C++
Palindromic
hdu 1061
Rightmost
Digit(水题,打表)
小记:原来任意数对0取模是个RE。 思路:从0-9,每一位数字的N次方都会有一个循环节,找出这个循环节,制成表。然后输出一个就可直接输出一个了。因为只看最右边那个位的数,所以先取模保存个位,然后将输入的数对该个位数字的循环节取模,输出即可。代码:#include #include #include #include #include usingnamespacestd; #definemst(
ljd4305
·
2014-04-06 12:00
hdu
Rightmost
Digit
RightmostDigitTimeLimit:2000/1000MS(Java/Others) MemoryLimit:65536/32768K(Java/Others)TotalSubmission(s):29473 AcceptedSubmission(s):11243ProblemDescriptionGivenapositiveintegerN,youshouldoutput
u014028231
·
2014-03-21 17:00
Rightmost
Digit
#include usingnamespacestd; intmain(){ intn,a,result; cin>>n; for(inti=0;i>a; intb=a%10; intc=a%4; if(c==0) { cout<<(b*b*b*b)%10<
颜建海
·
2014-03-14 11:00
hdu
Rightmost
Digit
RightmostDigitTimeLimit:2000/1000ms(Java/Other) MemoryLimit:65536/32768K(Java/Other)TotalSubmission(s):24 AcceptedSubmission(s):11Font:TimesNewRoman|Verdana|GeorgiaFontSize:←→ProblemDescriptionGiv
u014028231
·
2014-02-19 17:00
[leetcode]Trapping Rain Water
扫描leftmost和
rightmost
class Solution { public: int trap(int A[], int n) { if(n < 3
·
2014-01-10 14:00
LeetCode
Rightmost
Digit
TimeLimit:2000/1000MS(Java/Others) MemoryLimit:65536/32768K(Java/Others)TotalSubmission(s):26463 AcceptedSubmission(s):10175ProblemDescriptionGivenapositiveintegerN,youshouldoutputthemostrightdi
zxdfc
·
2013-11-02 13:00
查找二叉搜索树中小于某个节点的最大值
Node*
rightMost
(Node*n) { if(n->right==NULL) { returnn; } while(n->right) { n=n->right; } returnn; }
brucehb
·
2013-10-04 12:00
HDU 1061
Rightmost
Digit (数学&三种解法)
RightmostDigithttp://acm.hdu.edu.cn/showproblem.php?pid=1061TimeLimit:2000/1000MS(Java/Others) MemoryLimit:65536/32768K(Java/Others)ProblemDescriptionGivenapositiveintegerN,youshouldoutputthemostri
synapse7
·
2013-08-27 16:00
ACM
HDU
hdu1061-
Rightmost
Digit(附20循环的规律解法和附快速幂简单原理)
http://acm.hdu.edu.cn/showproblem.php?pid=10611.快速幂实现a^N求3^999(a=3,N=999):3^999=3*3*3*…*3,直接乘要做998次乘法。快速幂方法实质使用了二分法进行时间优化: tmp+ = tmp-* a-;3^1 = 3* 13^2 =(3^1)*(3^1)3^4 =(3^2) *(3^2)…………3^256=(3^12
liujie619406439
·
2013-06-09 15:00
算法
快速幂
hud 1061
Rightmost
Digit
/........................................................................................................................................\打表找规律,m=123456789101112131415161718192021222324252728293031...
u010138811
·
2013-05-16 20:00
HDU
HDU 1061
Rightmost
Digit
l Problem-solvingideas:做这个题首先要知道两个数学规律://任何两个数相乘的最低位一定是它们最低位相乘所得结果的最低位//同一个数连乘结果是具有周期性的,周期不大于10方法一:利用以上两个规律构造出乘积周期性的解法。方法二:直接利用快速幂l Sourcecode:方法一:#include#include intmain(){ int
xu3737284
·
2013-04-25 20:00
HDOJ 1061
Rightmost
Digit 13.04.21周赛结题报告
RightmostDigitTimeLimit:2000/1000MS(Java/Others)MemoryLimit:65536/32768K(Java/Others)TotalSubmission(s):23861AcceptedSubmission(s):9096ProblemDescriptionGivenapositiveintegerN,youshouldoutputthemostri
SIOFive
·
2013-04-24 16:00
算法
HDU 1061
Rightmost
Digit
Problem DescriptionGivenapositiveintegerN, youshouldoutputthemostrightdigitofN^N.InputTheinputcontainsseveral testcases.ThefirstlineoftheinputisasingleintegerTwhichisthe numberoftestcases.Ttestcasesfo
lphy2352286B
·
2013-04-16 14:00
上一页
1
2
3
下一页
按字母分类:
A
B
C
D
E
F
G
H
I
J
K
L
M
N
O
P
Q
R
S
T
U
V
W
X
Y
Z
其他