Untitled

mail@pastecode.io avatar
unknown
plain_text
18 days ago
532 B
1
Indexable
Never
#include <bits/stdc++.h>
using namespace std;

string anh4(string s)
{
    if (s.length() <= 4)
    {
        return string(4 - s.length(), '0') + s;
    }
    else
    {
        return s.substr(s.length() - 4);
    }
}

int main()
{
    int a1, n;
    cin >> a1 >> n;
    string a = to_string(a1);
    a = anh4(a);

    for (int i = 1; i < n; ++i)
    {

        int num = stoi(a);
        num *= num;
        a = to_string(num);
        a = anh4(a);
    }
    cout << a << endl;

    return 0;
}
Leave a Comment