不好意思再一次的水了,但這次的題目是我自己推出來的,雖然沒有多大難度但是這種關於數學的題目我是從心裏不想去做,今天開了一個頭。並且也應用了上篇報告關於 std::ios::sync_with_stdio(false) 的使用。
#include <iostream>
#include <cstdio>
#include <cmath>
using namespace std;
int main()
{
std::ios::sync_with_stdio(false);
long a, b, n;
while (cin >> a >> b) {
a %= 10;
b %= 4;
if (b == 0)
b = 4;
n = pow(a, b);
cout << n % 10 << endl;
}
return 0;
}
之前使用了int表示a, b, n然後WA,再使用long,然後加上 a %= 10 這句成功AC,orz。。