现在的位置: 首页 > 综合 > 正文

hdu1093

2013年08月16日 ⁄ 综合 ⁄ 共 260字 ⁄ 字号 评论关闭
//a^b循环节为4
#include <iostream>
#include <cmath>
using namespace std;

int cal(int a,int b)
{
    a = a%10;
    if( b >= 1 && b <= 4)
      return ((int)pow((float)a,(float)b))%10;
    else if(b > 4)
        return cal(a,b%4);
    else if(b == 0)
         return cal(a,4);
}

int A,B;

int main()
{
    while(cin>>A>>B)
    {
        cout<<cal(A,B)<<endl;
    }
    return 0;
}

抱歉!评论已关闭.