#include<bits/stdc++.h>
using namespace std;
int qpow(int m,int n){
int k=m,s=1;
while(n){
if(n&1)s=s*k%29;
k=k*k%29;
n>>=1;
}
return s;
}
int main(){
int n;
while(scanf("%d",&n)&&n)
printf("%d\n",9*(qpow(2,2*n+1)-1)*(qpow(3,n+1)-1)*(qpow(167,n+1)-1)%29);
return 0;
}
HDU 1452 Happy 2004
最新推荐文章于 2020-07-27 19:49:32 发布