您的位置:首页 > 其它

HDU1058(还是简单dp)

2014-06-04 08:43 141 查看
昨天一个数据挖掘的公司跟我说我面试通过了,问我去不去,我在犹豫,因为我在等百度的面试。我在想,如果我说去了,那么意味着我未来的第一份工作极度有可能是数据挖掘,虽然数据挖掘是未来的正道~(起码比研发更吃香..)但是我目前兴致不是特别高,犹豫犹豫犹豫,今天就要给答复了。烦恼!如果我放弃了,那么我就不能赌一盘百度,如果我坚持,再跪掉百度,那么我这个暑假实习就可以算是很失败了。有没有朋友给些意见?

今天的题目还是dp,在我6月份,我只做dp。今天心情很奇怪,效率很低。这么简单的题,我都调了非常久,这样下去,我还有什么可能打区赛(╮(╯▽╰)╭,队友都没有!!)

问因子只含有2,3,5,7的第k个数是什么?

输出比较蛋疼~出题人是要卡输出格式的节奏~

/***********************************************************
> OS : Linux 3.2.0-60-generic #91-Ubuntu
> Author : yaolong
> Mail : dengyaolong@yeah.net
> Time : 2014年06月04日 星期三 07:11:04
**********************************************************/
#include<iostream>
#include<cstdio>
#include<string>
#include<cstring>
#include<algorithm>
#include<set>
using namespace std;
typedef long long LL;
LL dp[6543];
int f[]={2,3,5,7};
int ind[]={1,1,1,1};
LL tmp[]={1,1,1,1};
int mp[]={0,1,2,3};
int cmp(int a,int b){
return tmp[a]<tmp[b];

}
int main(){

int n;
memset(dp,0,sizeof(dp));
dp[1]=1;
int ans=1,i;
for(ans=2;ans<=5842;ans++){
for(i=0;i<4;i++){
tmp[i]=f[i]*dp[ind[i]];
}
sort(mp,mp+4,cmp);
int q=0;
while(q<4&&tmp[mp[0]]==tmp[mp[q]]){
ind[mp[q]]++;
q++;
}
dp[ans]=tmp[mp[0]];
}
while(scanf("%d",&n)&&n){
if(n%100==11 || n%100==12 || n%100==13)
printf("The %dth humble number is %lld.\n",n,dp
);
else if(n%10==1)
printf("The %dst humble number is %lld.\n",n,dp
);
else if(n%10==2)
printf("The %dnd humble number is %lld.\n",n,dp
);
else if(n%10==3)
printf("The %drd humble number is %lld.\n",n,dp
);
else
printf("The %dth humble number is %lld.\n",n,dp
);
}

return 0;
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  HDU1058