Josif_tepe

Untitled

Apr 10th, 2026
271
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.48 KB | None | 0 0
  1. #include <iostream>
  2. #include <algorithm>
  3. using namespace std;
  4.  
  5. int main()
  6. {
  7.     int n;
  8.     cin >> n;
  9.    
  10.     int niza[n];
  11.     for(int i = 0; i < n; i++) {
  12.         niza[i] = i + 1;
  13.     }
  14.    
  15.    
  16.     long long zbir = 0;
  17.     do {
  18.         int broj = 0;
  19.         for(int i = 0; i < n; i++) {
  20.             broj = broj * 10 + niza[i];
  21.         }
  22.         zbir += broj;
  23.        
  24.     } while(next_permutation(niza, niza + n));
  25.    
  26.     cout << zbir << endl;
  27.     return 0;
  28. }
  29.  
Advertisement
Add Comment
Please, Sign In to add comment