HDU 1097

来源:互联网 发布:单片机65536 编辑:程序博客网 时间:2024/06/12 23:26

求n^n的最后一位,快速幂,主要是留下整理的头文件

#include <bits/stdc++.h>typedef long long ll;typedef double db;#define rep(i,a,n) for (int i=a;i<n;i++)#define per(i,a,n) for (int i=n-1;i>=a;i--)#define mp make_pair#define pb push_back#define fi first#define se second#define all(x) (x).begin(),(x).end()#define SZ(x) ((int)(x).size())#define sspeed  ios::sync_with_stdio(false);cin.tie(0)using namespace std;const int inf = 0x3f3f3f3f;const int mod = int(1e9) + 7;const int md=10;ll mypow(ll a,ll e){    if(e==0)return 1;    return e&1?mypow(a,e-1)*a%md:mypow(a*a%md,e>>1);}inline ll gcd(ll a,ll b) {return b?gcd(b,a%b):a;}inline int  read(){    int x=0,f=1;char ch=getchar();    while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}    while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}    return x*f;}//-------- headint main(){   ll a,b;   while(cin>>a>>b) cout<<mypow(a,b)<<endl;    return 0;}



原创粉丝点击