求n^n最右边的一位

找出规律即可

View Code
#include<iostream>
using namespace std;

int main()
{
    int T,n,ans,t;
    cin>>T;
    while(T--)
    {
        cin>>n;
        t=n%10;
        n=(n-1)%4+1;
        for(ans=1;n--;ans*=t);
        cout<<ans%10<<endl;
    }
    return 0;
}

相关文章:

  • 2022-01-08
  • 2022-12-23
  • 2022-12-23
  • 2021-08-02
  • 2022-12-23
  • 2021-08-17
  • 2021-07-20
猜你喜欢
  • 2021-11-06
  • 2021-08-27
  • 2021-10-04
  • 2021-06-25
  • 2021-06-18
  • 2021-05-30
  • 2022-12-23
相关资源
相似解决方案