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;
}
越来越懒了
难过
刷水题
规律题
#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;
}
相关文章推荐
- 【51Nod】1004 n^n的末位数字
- 51nod --1004 n^n的末位数字(一级算法题)
- 51nod 1004 n^n的末位数字(快速幂)
- 51nod 1004 n^n的末位数字
- 51NOD 1004 n^n的末位数字
- n^n的末位数字 51Nod - 1004
- 51Nod 1004 n^n的末位数字
- 51Nod-1004-n^n的末位数字
- 51Nod--1004 n^n的末位数字
- 51nod 1004 n^n的末位数字
- 【51nod】 1004 - n^n的末位数字
- 51nod 1004 n^n的末位数字
- 51Nod 1004 n^n的末位数字
- 51Nod——1004 n^n的末位数字
- 51nod 1004 n^n的末位数字
- 51nod 1004 n^n的末位数字
- 51Nod 1004 n^n的末位数字(日常复习快速幂,莫名的有毒,卡mod值)
- 51Nod-1004 n^n的末位数字【快速模幂】
- 51nod 1004:n^n的末位数字
- [51nod]1004 n^n的末位数字