http://acm.hdu.edu.cn/showproblem.php?pid=1061
//直接模拟会Time Limit Exceeded //故猜想此题数据上会有规律之类的,通过对数据分析,发现数据n次方的规律: //n>4时每次四循环回来,并且数据只由个位数决定 #include <iostream> #include <cmath> using namespace std; int main() { int T, n; int ta, tb; cin >> T; while (T--) { cin >> n; ta = n%10; tb = n%4; if (tb == 0) tb = 4; printf("%d\n", (int)pow((double)ta, tb)%10); } return 0; }