CRUELL - Cô giáo dạy toán, phần I
Tác giả: hieult
Ngôn ngữ: C++
#include<cstdio>
#include<cmath>
#include<cstring>
#include<cstdlib>
#include<cassert>
#include<ctime>
#include<algorithm>
#include<iterator>
#include<iostream>
#include<cctype>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<queue>
#include<list>
//#include<conio.h>
#define ep 0.000000001
#define maxn 10011
#define oo 1111111111
#define base 1000000000
#define TR(c, it) for(typeof((c).begin()) it=(c).begin(); it!=(c).end(); it++)
double const PI=4*atan(1);
using namespace std;
typedef pair<int, int> II;
typedef vector<int> VI;
typedef vector<II> VII;
typedef vector<VI> VVI;
typedef vector<VII> VVII;
int n,f[maxn][4],x[maxn],cha[maxn],u,v,KQ,t;
VVI T;
//VVI::iterator it;
int main(){
int kq[15011];
char s[1000111];
int maxKQ = 0;
char *s1;
int n,p,du,i;
scanf("%d %d",&n,&p);
if(n==2 && p%2==0){
n = 4; p /=2;
}
long long the;
kq[0] = 1;
for(int k = 0;k<p;k++){
du = 0;
for(i = 0;i<=maxKQ||du;i++){
the = n*1LL*kq[i]+du;
if(the>=base){
kq[i] = the%base;
du = the/base;
}
else{
kq[i] = the;
du = 0;
}
if(kq[i] && i>maxKQ) maxKQ = i;
}
}
s1 = s;
for( i = maxKQ;i>=0;i--){
if(i==maxKQ) sprintf(s1,"%d",kq[i]);
else sprintf(s1,"%09.9d",kq[i]);
while(*s1) s1++;
}
for(i = 0;s[i];i+=70)
printf("%.70s\n",&s[i]);
// getch();
}