Cod sursa(job #729884)
| Utilizator | Data | 30 martie 2012 18:09:07 | |
|---|---|---|---|
| Problema | Ridicare la putere in timp logaritmic | Scor | 10 |
| Compilator | cpp | Status | done |
| Runda | Arhiva educationala | Marime | 0.46 kb |
#include<fstream>
#define ll long long
#define mod 1999999973
using namespace std;
ifstream fin("lgput.in");
ofstream fout("lgput.out");
ll a,b,n,p;
ll rid( ll n, ll p )
{
if( p == 1)
return n;
if(p % 2 == 0 )
{
ll t = rid( n , p/2 ) % mod;
return (t * t ) % mod ;
}
else
return rid( n, p-1) %mod ;
}
void cit()
{
fin >> n >> p;
fout << rid( n , p );
}
int main()
{
cit();
fin.close();
fout.close();
return 0;
}