hdu 1097 A hard puzzle

/...............................................................................................................................................................................................................\

刚开始写的代码用的是int,wa了,改用——int64就ac了,因为a*a超出int的范围了。

\............................................................................................................................................................................................................../



#include<stdio.h>
#include <iostream>
#include<string.h>
#include<stdlib.h>
#include<math.h>
#include<algorithm>
#include<list>
#include<vector>
#pragma comment(linker,"/STACK:102400000,102400000")
using namespace std;

int main()
 {
      __int64 a,b,t;//用int就是wa了,a*a超出int的范围了
      while(scanf("%I64d%I64d",&a,&b)!=EOF)
      {
          t=1;
          while(b)
          {
              if(b%2==1)
              {
                  t=t*a%10;
              }
              a=a*a%10;
              b=b/2;
          }
          printf("%I64d\n",t%10);
      }
      return 0;
 }


你可能感兴趣的:(HDU,math.h)