Cod sursa(job #3353939)

Utilizator 3fr3mFarcasanu Efrem 3fr3m Data 12 mai 2026 19:05:34
Problema Range minimum query Scor 0
Compilator cpp-64 Status done
Runda Arhiva educationala Marime 1.38 kb
#include <fstream>

using namespace std;

ifstream cin("rotire25.in");
ofstream cout("rotire25.out");

int pc(long long n)
{
    while (n > 9)
    {
        n /= 10;
    }
    return n;
}

/*
long long og(long long n)
{
    long long ogl = 0;
    long long c;
    while (n > 0)
    {
        c = n % 10;
        ogl = ogl * 10 + c;
        n /= 10;
    }
    return ogl;
}
*/

long long eliminZeroSiOg(long long x)
{
    long long y = 0;
    while (x > 0)
    {
        long long c = x % 10;
        if (c != 0)
        {
            y = 10 * y + c;
        }
        x /= 10;
    }
    return  y;
}

int main()
{
    long long x, k, c;
    cin >> c >> x >> k;
    if (c == 1)
    {
        if (x % 10 == 0)
        {
            cout << 0;
        }
        else if (x % 5 == 0)
        {
            cout << 5 * pc(x);
        }
        else
        {
            long long p = 1;
            for (int i = 1; i <= k; i++)
            {
                p *= x;
            }
            cout << (p % 10) * pc(x);
        }
    }

    if (c == 2)
    {
        while (k > 0)
        {
            x = eliminZeroSiOg(x*5);
            k--;
            if (k == 0)
            {
                break;
            }

            x = eliminZeroSiOg(x*2);
            k--;
        }
        cout << x;
    }
    return 0;
}