HDU1061

规律题

View Code
 1 /*
 2 n^n 个位
 3 */
 4 #include<stdio.h>
 5 #include<stdlib.h>
 6 #include<string.h>
 7 #include<iostream>
 8 #include<algorithm>
 9 #include<queue>
10 #include<map>
11 #include<math.h>
12 using namespace std;
13 const int maxn = 1005;
14 const int inf = 0x7fffffff;
15 int main(){
16     int T;
17     scanf("%d",&T);
18     while( T-- ){
19         int n;
20         scanf("%d",&n);
21         int cir;
22         if( n%4==0 ) cir=4;
23         else cir=n%4;
24         n%=10;
25         int tmp=1;
26         while( cir-- ){
27             tmp*=n;
28         }
29         printf("%d\n",tmp%10);
30     }
31     return 0;
32 }

 

转载于:https://www.cnblogs.com/xxx0624/archive/2012/12/14/2818621.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值