CSES - Datatähti 2023 alku - Results
Submission details
Task:Kertoma
Sender:fatihmerickoc
Submission time:2022-11-10 19:24:25 +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(long long n)
{
  for (int i = 1;; i++) {
    if (n % i == 0) {
      n /= i;
    }
    else {
      break;
    }
  }
 
  if (n == 1) {
    return true;
  }
  else {
    return false;
  }
}

  void doReverseFactorial(long long num)
  {
  long long 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(long long vector[], int vectorSize)
{
  long long num = 0;
  for (int i = 0; i < vectorSize; i++) {
    num *= 10;
    num += vector[i];
  }
  doReverseFactorial(num);
}
 
// Function to find the permutations
void findPermutations(long long vector[], int vectorSize)
{
 
  // Sort the given array 
  // Find all possible permutations
  do {
    display(vector, vectorSize);
  } while (next_permutation(vector, vector + vectorSize));
}

int main(){
  int numberDigits[10];
  vector<long long> 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();
  long long arr[vectorSize];
    for (int i = 0; i < vectorSize; i++) {
        arr[i] = realNumbers[i];
    }


  findPermutations(arr, vectorSize);

  return 0;
}