您的位置:首页 > 其它

51nod 1004 n^n的末位数字

2017-08-20 14:22 281 查看
点这里

越来越懒了

难过

刷水题

规律题

#include <iostream>
#include <stdio.h>
#include <algorithm>
using namespace std;
typedef long long ll;
int ans[10][5]{ {0},{1},{2,4,8,6},{3,9,7,1},{4,6},{5},{6},{7,9,3,1},{8,4,2,6},{9,1} };
int main()
{
int n;
while (cin >> n)
{
int x = n % 10;
if (x == 0 || x == 1 || x == 5 || x == 6)
cout << ans[x][0] << endl;
else if (x == 4 || x == 9)
cout << ans[x][(n-1)% 2] << endl;
else
cout << ans[x][(n-1)% 4] << endl;
}

return 0;
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: