Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <cmath>
- using namespace std;
- int main() {
- int p, n;
- cin >> p >> n;
- for(int i = 0; i < n; i++) {
- int tmp = p;
- int treta_cifra = tmp % 10;
- tmp /= 10;
- int vtora_cifra = tmp % 10;
- tmp /= 10;
- int prva_cifra = tmp % 10;
- tmp /= 10;
- int sleden_broj = prva_cifra * prva_cifra + vtora_cifra * vtora_cifra + treta_cifra * treta_cifra;
- p = sleden_broj;
- }
- cout << p << endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement