Untitled
unknown
plain_text
a year ago
532 B
9
Indexable
#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;
}
Editor is loading...
Leave a Comment