Cod sursa(job #2501329)

Utilizator PetraPetra Hedesiu Petra Data 29 noiembrie 2019 15:27:01
Problema Ridicare la putere in timp logaritmic Scor 30
Compilator cpp-64 Status done
Runda Arhiva educationala Marime 3 kb
#include <iostream>
#include <fstream>
#include <vector>
#include <algorithm>
#include <sstream>
#include <stack>
using namespace std;

//vector <int> v;
int main()
{
   /* int n;
    cin >> n;
    for (int i=0; i<n; i++)
    {
        int x;
        cin >> x;
        v.push_back(x);
    }
    sort (v.begin(), v.end());
    int cn=0;
    int sol=0;
    for (int i=1; i<n; i++)
    {
        if (v[i]==v[i-1])
        {
            cn++;
        }
        else
        {
            sol = sol + (cn*(cn+1)/2);
            cn=0;
        }
    }
    if (cn>0)
    {
        sol = sol + (cn*(cn+1)/2);
    }
    cout << sol << "\n";*/




   /* stack<int> st;
    string s;
    getline(cin, s);
    cout << s;
    stringstream ss(s);
    string op;
    while (ss>>op)
    {
        cout << op << endl;
        if (op[0]>='0' && op[0]<= '9')
        {
            stringstream opstream(op);
            int x;
            opstream >> x;
            st.push(x);
        }
        if (op=="dup")
        {
            if (st.size()==0)
            {
                cout << "-1\n";
                return 0;
            }
            st.push(st.top());
        }
        if (op=="pop")
        {
            if (st.size()==0)
            {
                cout << "-1\n";
                return 0;
            }
            st.pop();
        }
        if (op=="+")
        {
            if (st.size()==0)
            {
                cout << "-1\n";
                return 0;
            }
            int x1=st.top();
            st.pop();
            if (st.size()==0)
            {
                cout << "-1\n";
                return 0;
            }
            int x2=st.top();
            st.pop();
            st.push(x1+x2);
        }
        if (op=="-")
        {
            if (s.size()==0)
            {
                cout << "-1\n";
                return 0;
            }
            int x1=st.top();
            st.pop();
            if (s.size()==0)
            {
                cout << "-1\n";
                return 0;
            }
            int x2=st.top();
            st.pop();
            st.push(x1-x2);
        }
    }
    if (st.size()==0)
    {
        cout << "-1\n";
        return 0;
    }
    cout << st.top();*/




    /*int n;
    cin >> n;
    for (int i=0; i<n; i++)
    {
        int x;
        cin >> x;
        v.push_back(x);
    }
    int cn=0, sol=0;
    for (int i=0; i<n; i++)
    {
        if (v[i]-v[i-1] == v[i-1]-v[i-2])
        {
            cn++;
        }
        else
        {
            sol = sol + (cn*(cn+1))/2;
            cn=0;
        }
    }
    if (cn>0)
    {
        sol = sol + (cn*(cn+1))/2;
    }
    cout << sol << "\n";*/



    long long a, b, p=1;
    ifstream fin ("lgput.in");
    ofstream fout ("lgput.out");
    fin >> a >> b;
    while (b)
    {
        p=p*a%1999999973;
        b--;
    }
    fout << p;
    return 0;
}