Cod sursa(job #3338332)

Utilizator baragan30Baragan Andrei baragan30 Data 2 februarie 2026 18:59:14
Problema Factorial Scor 0
Compilator cpp-64 Status done
Runda Arhiva de probleme Marime 1.02 kb
// Se citesc 2 numere ( n si x). Apoi se citeste un sir de n numere naturale. 
// Vrem sa aflam pe ce pozitie se afla x in sirul de n elemente( incepand de la 0)
#include <iostream>

using namespace std;
// n = 5, x = 3
// v = 4 3 3 2 7

int main() { // 0   1   2   3   4   5   6   7   8    9
	int v[100] = {101,102,103,104,105,106,107,108,109, 110}, n= 10, x;
  int poz = -1;#include <bits/stdc++.h>

using namespace std;
ifstream fin ("fact.in");
ofstream fout("fact.out");
int f(int n){
    int x=5,numere=0;
    while (x<=n){
        numere+=n/x;
        x=x*5;
    }
    return numere;
}
int main()
{
    int n;
    fin >> n;
    int st=1,dr=1000;
    while (st<dr){
        int mij=(st+dr)/2;
        if (n>f(mij))
            st=mij+1;
        else
            dr=mij;
    }
    fout << st;
    return 0;
}
	cin >> n >> x;
	for(int i =0 ; i < n ; i ++)
		cin >> v[i];

  for(int i = 0 ; i < n ; i++){
    if(v[i] == x){ 
      poz = i;
      i = n;
    }
  }
  cout << poz;
	return 0;
}