CSES - Datatähti 2023 alku - Results
Submission details
Task:Kertoma
Sender:fatihmerickoc
Submission time:2022-11-10 17:56:14 +0200
Language:C++ (C++11)
Status:COMPILE ERROR

Compiler report

input/code.cpp:1:10: fatal error: /Users/fatihmerickoc/stdc++.h: No such file or directory
    1 | #include "/Users/fatihmerickoc/stdc++.h"
      |          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
compilation terminated.

Code

#include "/Users/fatihmerickoc/stdc++.h"
#include <iostream>
#include <algorithm>
#include <cstring>
using namespace std;

  bool isFactorial(int n)
{
  for (int i = 1;; i++) {
    if (n % i == 0) {
      n /= i;
    }
    else {
      break;
    }
  }
 
  if (n == 1) {
    return true;
  }
  else {
    return false;
  }
}

  void doReverseFactorial(int num)
  {
  int reverse = num;
  bool ans = isFactorial(reverse);

  if (ans == 1)
  {
    for (int a = 2; reverse != a; a++)
    {
    reverse = reverse / a;
    }
    cout << to_string(reverse) << endl;
  }
  
 
}

void display(int vector[], int vectorSize)
{
  int retval = 0;
  for (int i = 0; i < vectorSize; i++) {
   retval *= 10;
   retval += vector[i];  
  }
  doReverseFactorial(retval);
}
 
// Function to find the permutations
void findPermutations(int vector[], int vectorSize)
{
 
  // Sort the given array
  sort(vector, vector + vectorSize);
 
  // Find all possible permutations
  do {
    display(vector, vectorSize);
  } while (next_permutation(vector, vector + vectorSize));
}

int main(){
  int numberDigits[10];
  vector<int> realNumbers;

  //read all 10 digits
  for (int i = 0; i < 10; i++)
  {
    cin >> numberDigits[i];
  }

  //add elements to vector 
  for (int f = 0; f < 10; f++)
  {
    if (numberDigits[f] != 0)
    {
      int times = numberDigits[f];
      for (int x = 0; x < times; x++)
      {
        realNumbers.push_back(f);
      }
    }
  }

  int vectorSize = realNumbers.size();
  int arr[vectorSize];
    for (int i = 0; i < vectorSize; i++) {
        arr[i] = realNumbers[i];
    }


  findPermutations(arr, vectorSize);

  return 0;
}