这道简单的C语言题请用最简单的代码解决一下。。

来源:百度知道 编辑:UC知道 时间:2024/06/13 15:36:35
A hard puzzle
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 4092 Accepted Submission(s): 1403

Problem Description
lcy gives a hard puzzle to feng5166,lwg,JGShining and Ignatius: gave a and b,how to know the a^b.everybody objects to this BT problem,so lcy makes the problem easier than begin.
this puzzle describes that: gave a and b,how to know the a^b's the last digit number.But everybody is too lazy to slove this problem,so they remit to you who is wise.

Input
There are mutiple test cases. Each test cases consists of two numbers a and b(0<a,b<=2^30)

Output
For each test case, you should output the a^b's last digit number.

Sample Input
7 66
8 800

Sample Output
9
6

我的老超时郁闷。。。。
#include<stdio.h>
void main()
{
long int i,x,n,a,b,t,max;
while(scanf("%ld %ld",&

http://acm.hdu.edu.cn/statistic.php?pid=1097
目前我排名第一,哈哈

#include <stdio.h>
int main()
{
int n,m,d;

while(scanf("%d%d",&n,&m)>0)
{
for(d=1,n%=10,m=m%4+4;m;m--)
d=d*n%10;
printf("%d\n",d);
}
return 0;
}

挺有意思的
输入 A B
你可以取A的最后一位就好了,然后执行A*A*A。。。如果发现结果的最后一位变成A,则记录A相乘的个数n
用B对个数n取余,然后就进行余数个A相乘就可以了
相乘的次数估计不会超过20次吧