Pagini recente » Cod sursa (job #3334920) | Cod sursa (job #3332344) | Cod sursa (job #1395670) | Cod sursa (job #2420698) | Cod sursa (job #3338332)
// 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;
}