Pagini recente » Monitorul de evaluare | Cod sursa (job #752964) | Benzina | Cod sursa (job #151796) | Cod sursa (job #374076)
Cod sursa(job #374076)
#include<fstream>
using namespace std;
unsigned int s1[3000001], s2[3000001];
int main(){
ifstream f("sdo.in");
ofstream g("sdo.out");
unsigned int n, k, i, j, ind,m;
f>>n>>k;
--k;
for(i=0;i<n;i++)
f>>s1[i];
unsigned int *p1, *p2, *aux;
p1=s1;p2=s2;
for(m=0;m<32;m+=8){
ind=0;
for(i=0;i<256;i++){
for(j=0;j<n;j++)
if( ( ( p1[j]>>m ) & 255 ) == i )
p2[ind++]=p1[j];
}
aux=p1;p1=p2;p2=aux;
}
g<<p1[k]<<endl;
f.close();
g.close();
}