比赛 |
20130725暑期B班1测 |
评测结果 |
AAAAAAAAAAAAAA |
题目名称 |
残酷的数学老师 |
最终得分 |
100 |
用户昵称 |
王者自由 |
运行时间 |
0.701 s |
代码语言 |
C++ |
内存使用 |
0.38 MiB |
提交时间 |
2012-07-18 11:10:49 |
显示代码纯文本
#include <cstdio>
#include <cstring>
#include <string>
#include <cmath>
#include <iostream>
#include <algorithm>
using namespace std;
const int N = 15000 + 10;
int n, p;
struct bign{
int len, s[N];
bign() {
memset(s, 0, sizeof(s));
len = 1;
}
bign(int num) {
*this = num;
}
bign(const char* num) {
*this = num;
}
bign operator = (int num) {
char s[N];
sprintf(s, "%d", num);
*this = s;
return *this;
}
bign operator = (const char* num) {
len = strlen(num);
for(int i = 0; i < len; i++) s[i] = num[len-i-1] - '0';
return *this;
}
string str() const {
string res = "";
for(int i = 0; i < len; i++) res = (char)(s[i] + '0') + res;
if(res == "") res = "0";
return res;
}
void clean() {
while(len > 1 && !s[len-1]) len--;
}
bign operator * (const bign& b) {
bign c; c.len = len + b.len;
for(int i = 0; i < len; i++)
for(int j = 0; j < b.len; j++)
c.s[i+j] += s[i] * b.s[j];
for(int i = 0; i < c.len-1; i++){
c.s[i+1] += c.s[i] / 10;
c.s[i] %= 10;
}
c.clean();
return c;
}
};
int main() {
freopen("cruel1.in", "r", stdin);
freopen("cruel1.out", "w", stdout);
scanf("%d %d", &n, &p);
bign A = n;
for(int i=1; i<p; i++)
A = A * n;
string s = A.str();
for(int i=0; i<s.length(); i++) {
printf("%c", s[i]);
if(i && (i+1) % 70 == 0) printf("\n");
} printf("\n");
return 0;
}