Advertisement
Josif_tepe

Untitled

Mar 2nd, 2024
717
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.53 KB | None | 0 0
  1. #include <iostream>
  2. #include <cmath>
  3. using namespace std;
  4. int main() {
  5.     int p, n;
  6.     cin >> p >> n;
  7.    
  8.     for(int i = 0; i < n; i++) {
  9.         int tmp = p;
  10.         int treta_cifra = tmp % 10;
  11.         tmp /= 10;
  12.         int vtora_cifra = tmp % 10;
  13.         tmp /= 10;
  14.         int prva_cifra = tmp % 10;
  15.         tmp /= 10;
  16.         int sleden_broj = prva_cifra * prva_cifra + vtora_cifra * vtora_cifra + treta_cifra * treta_cifra;
  17.        
  18.         p = sleden_broj;
  19.    
  20.     }
  21.     cout << p << endl;
  22.     return 0;
  23. }
  24.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement