Cod sursa(job #3237539)
| Utilizator | Data | 9 iulie 2024 21:13:45 | |
|---|---|---|---|
| Problema | Ridicare la putere in timp logaritmic | Scor | 100 |
| Compilator | cpp-64 | Status | done |
| Runda | Arhiva educationala | Marime | 0.45 kb |
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
ifstream fin( "lgput.in" );
ofstream fout( "lgput.out" );
const int MOD = 1999999973;
int lgpow( int a, ll n ) {
int p = 1;
for ( ; n; n >>= 1 ) {
if ( n & 1 ) p = (ll)p * a % MOD;
a = (ll)a * a % MOD;
}
return p;
}
int main() {
ios_base::sync_with_stdio(0);
fin.tie(0);
ll a, n;
fin >> a >> n;
fout << lgpow(a % MOD, n);
fin.close();
fout.close();
return 0;
}
