标签:main ret std hashtable hash stdio.h using tab void
#include<stdio.h>
#include<algorithm>
using namespace std;
int Table[1000]={0};
bool hashtable[105];
bool cmp(int a,int b){ return a>b;}
void put(){
int temp;scanf("%d",&temp);
Table[temp]++;hashtable[temp]=true;
if(Table[temp]>1) return;
while(temp!=1){
if(temp%2==0){
temp/=2;
if(temp<=100) Table[temp]++;
}else{
temp=(temp*3+1)/2;
if(temp<=100) Table[temp]++;
}
}
}
int main(){
int N,shuchu[100],num=0;
scanf("%d",&N);
for(int i=0;i<N;i++){ put(); }
for(int i=2;i<=100;i++){
if(Table[i]==1&&hashtable[i]==true) shuchu[num++]= i;
}
if(num!=0) sort(shuchu,shuchu+num,cmp);
for(int i=0;i<num;i++){
if(i!=0)printf(" ");
printf("%d",shuchu[i]);
}
return 0;
}
标签:main ret std hashtable hash stdio.h using tab void
原文地址:https://www.cnblogs.com/hebust/p/9498148.html