Cod sursa(job #1745129)
| Utilizator | Data | 21 august 2016 12:42:41 | |
|---|---|---|---|
| Problema | Ridicare la putere in timp logaritmic | Scor | 100 |
| Compilator | cpp | Status | done |
| Runda | Arhiva educationala | Marime | 0.6 kb |
#include <fstream>
#define REST 1999999973
#define ll (long long)
using namespace std;
int x, y;
void read();
int solve();
void write();
int main(){
read();
write();
return 0;
}
void read(){
ifstream fin ("lgput.in");
fin >> x >> y;
fin.close();
}
int solve(){
int p = 1;
while (y)
if (!(y%2))
x = ( ll x * ll x ) % REST,
y /= 2;
else p = ( ll p * ll x ) % REST,
--y;
return p;
}
void write(){
ofstream fout ("lgput.out");
fout << solve() << "\n";
fout.close();
}
