记录编号 101059 评测结果 AAAAAAAAAAAAAA
题目名称 [暑假培训2012] 残酷的数学老师 最终得分 100
用户昵称 GravatarOI永别 是否通过 通过
代码语言 C++ 运行时间 0.943 s
提交时间 2014-05-09 19:27:32 内存使用 0.42 MiB
显示代码纯文本
#include<cstdio>
#include<cstring>
#include<iostream>
using namespace std;
#define N 20100
struct BIGNUM{
	int x[N];
	inline void clean(){
		memset(x, 0, sizeof(x));
		return;
	}
	friend BIGNUM operator *(const BIGNUM & a,const BIGNUM & b){
		BIGNUM c; c.clean();		
		for (int i = 1; i <= a.x[0]; i ++){
			int tem = 0;
			for (int j = 1; j <= b.x[0]; j ++){
				tem = a.x[i] * b.x[j] + tem / 10 + c.x[i + j - 1] ;
				c.x[i + j - 1] = tem % 10;
			}
			if (tem / 10){
				c.x[i + b.x[0]] = tem / 10;
			}
		}
		c.x[0] = a.x[0] + b.x[0];
		while (c.x[c.x[0]] == 0 && c.x[0] > 1) c.x[0] --;
		return c;
	}
	
	friend void getnum(BIGNUM & a){
		a.clean();
		char s[100];
		scanf("%s", s);
		a.x[0] = strlen(s);
		for (int i = 0; i < a.x[0]; i ++){
			a.x[a.x[0] - i] = s[i] - 48;
		}
		return;
	}
	
	friend void print(const BIGNUM & a){
		int j = 0;
		for (int i = a.x[0]; i > 0; i --){
			printf("%d",a.x[i]);
			j ++;
			if (j % 70 == 0) puts("");
		}
		return;
	}
	
}a;
int b;

int main(){
	freopen("cruel1.in","r",stdin);
	freopen("cruel1.out","w",stdout);
	getnum(a); 
	scanf("%d",&b);
	BIGNUM c; c.clean();
	c.x[1] = c.x[0] = 1;
	while (b){
		if (b & 1) c = a * c;
		a = a * a;
		b >>= 1;
	}
	print(c);
	return 0;
}