开始编程之旅
刚刚学了一点C++,觉得挺有趣的,第一次写博客,不知道写什么,所以贴了一道我做的水题:
uva 136 Ugly Number:
原来以为简单的模拟暴力一下就解决了,可惜超时了,无奈之下,只好打表:
下面是code :
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <vector>
using namespace std;
int main()
{
printf("The 1500'th ugly number is 859963392.\n");
return 0;
}
/*
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <vector>
using namespace std;
int count=1;
int main()
{
int i=1;
while(count<1500)
{
int t=++i;
if (t%10==5||t%10==0)
while(t%5==0)
t/=5;
while(t%3==0)
t/=3;
while(t%2==0)
t/=2;
if (t==1)
count++;
}
printf("<%d>\n",i);
return 0;
}*/
请大神们多多指教。
posted on 2014-03-27 19:11 slowly stronger 阅读(156) 评论(0) 编辑 收藏 举报