Josif_tepe

Untitled

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