Răspuns :
533113193677352601874764398489
L-am calculat cu un algoritm din informatica.
Iata codul lui in C++ (daca are vre-o importanta)
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
void egall(string &x, string &y) //x.size()==y.size()
{
while (x.size()!=y.size())
if (x.size()<y.size()) x+='0'; else y+='0';
}
string addd(string x, string y)
{
egall(x,y);
string s; int q=0; char c;
for (int i=0; i<x.size(); i++,q/=10)
{
q+=(x[i]+y[i])-96;
c=(q % 10) + 48;
s+=c;
}
if (q)
{
c=q+48;
s+=c;
}
return s;
}
string sxi(string x, int y) // string * integer
{
string s; int q=0; char c;
for (int i=0; i<x.size(); i++,q/=10)
{
q+=(x[i]-'0') *y;
c=(q % 10) + 48;
s+=c;
}
if (q)
{
c= q + 48;
s+=c;
}
return s;
}
string sx10(string x, int y) // string * 10^y
{
for (; y; y--)
x='0'+x;
return x;
}
string zero(string x) //del '0' from begin
{
int i=0; string s;
while(x[i]=='0')
i++;
for (; i<x.size(); i++)
s+=x[i];
return s;
}
string multiply(string x, string y) // string * string
{
reverse(x.begin(),x.end());
reverse(y.begin(),y.end());
string s;
vector <string> s0(10);
for (int i=0; i<y.size(); i++)
{
if (s0[y[i]-'0']=="") s0[y[i]-'0']=sxi(x,y[i]-'0');
s=addd(s,sx10(s0[y[i]-'0'],i));
}
reverse(s.begin(),s.end());
return zero(s);
}
string spy(string s, int y) //string ^ y
{
string sol="1";
for (int i=0; (1<<i)<=y; i++)
{
if ( ((1<<i)&y)>0) sol=multiply(sol,s);
s=multiply(s,s);
}
return sol;
}
int main()
{
cout << spy("2009",9);
return 0;
}
L-am calculat cu un algoritm din informatica.
Iata codul lui in C++ (daca are vre-o importanta)
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
void egall(string &x, string &y) //x.size()==y.size()
{
while (x.size()!=y.size())
if (x.size()<y.size()) x+='0'; else y+='0';
}
string addd(string x, string y)
{
egall(x,y);
string s; int q=0; char c;
for (int i=0; i<x.size(); i++,q/=10)
{
q+=(x[i]+y[i])-96;
c=(q % 10) + 48;
s+=c;
}
if (q)
{
c=q+48;
s+=c;
}
return s;
}
string sxi(string x, int y) // string * integer
{
string s; int q=0; char c;
for (int i=0; i<x.size(); i++,q/=10)
{
q+=(x[i]-'0') *y;
c=(q % 10) + 48;
s+=c;
}
if (q)
{
c= q + 48;
s+=c;
}
return s;
}
string sx10(string x, int y) // string * 10^y
{
for (; y; y--)
x='0'+x;
return x;
}
string zero(string x) //del '0' from begin
{
int i=0; string s;
while(x[i]=='0')
i++;
for (; i<x.size(); i++)
s+=x[i];
return s;
}
string multiply(string x, string y) // string * string
{
reverse(x.begin(),x.end());
reverse(y.begin(),y.end());
string s;
vector <string> s0(10);
for (int i=0; i<y.size(); i++)
{
if (s0[y[i]-'0']=="") s0[y[i]-'0']=sxi(x,y[i]-'0');
s=addd(s,sx10(s0[y[i]-'0'],i));
}
reverse(s.begin(),s.end());
return zero(s);
}
string spy(string s, int y) //string ^ y
{
string sol="1";
for (int i=0; (1<<i)<=y; i++)
{
if ( ((1<<i)&y)>0) sol=multiply(sol,s);
s=multiply(s,s);
}
return sol;
}
int main()
{
cout << spy("2009",9);
return 0;
}