Cod sursa(job #2779671)

Utilizator alien14Razvan alien14 Data 4 octombrie 2021 18:20:45
Problema Ridicare la putere in timp logaritmic Scor 100
Compilator cpp-64 Status done
Runda Arhiva educationala Marime 1.47 kb
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define l long
#define d double
#define in int
#define si(x) scanf('%d', &x)
#define sl(x) scanf('%lld', &x)
#define ss(s) scanf('%s', s) 
#define pi(x) printf('%d', x)
#define pl(x) printf('%lld', x)
#define ps(s) printf('%s', s) 
#define pb push_back 
#define mp make_pair 
#define F first 
#define S second 
#define all(x) x.begin(), x.end() 
#define clr(x) memset(x, 0, sizeof(x))
#define sortall(x) sort(all(x)) 
typedef pair<int, int> pii; 
typedef pair<ll, ll> pl; 
typedef vector<int> vi; 
typedef vector<ll> vl; 
#define modulo 1999999973
#define for(i,a,b) for(int i=a;i<=b;i++)
typedef vector<pii> vpii;
ifstream fin("lgput.in");
ofstream fout("lgput.out");

void solve(){
    int n,H;
    cin>>n>>H;
    vector<int>a(n);
    for(i,0,n-1)
    {
        cin>>a[i];
    }

    sort(a.begin(),a.end());
    int y = a[a.size()-2], x = a[a.size()-1];

    if(H%(x+y) == 0)
        cout<<2*(H/(x+y));
    else if(H%(x+y) <= x)
        cout<<2*(H/(x+y)) + 1;
    else cout<<2*(H/(x+y)) + 2;
    cout<<'\n';

}

long long Logarithmic_Exponential(long long a, long long b)
{
    long long r = 1;
    while(b)
    {
        if(b%2==1)
            r = (r * a)%modulo;
        a = ((a%modulo) * (a%modulo))%modulo;
        b = (b / 2)%modulo;
    }
    return r%modulo;
}

int main() 
{
    ios_base::sync_with_stdio(0), fin.tie(0), fout.tie(0);
    long long a,b;
    fin>>a>>b;
    fout<<Logarithmic_Exponential(a,b);

    return 0;
}