求助!如何提高速度

dingqiqi2009 2009-03-08 01:20:40
Mike is very lucky, as he has two beautiful numbers, 3 and 5. But he is so greedy that he wants infinite beautiful numbers. So he declares that any positive number which is dividable by 3 or 5 is beautiful number. Given you an integer N (1 <= N <= 100000), could you please tell mike the Nth beautiful number?

Input

The input consists of one or more test cases. For each test case, there is a single line containing an integer N.

Output

For each test case in the input, output the result on a line by itself.

Sample Input

1
2
3
4



Sample Output

3
5
6
9



小弟原代码   
#include"stdio.h"
main()
{
int n;
int i,j;
while(scanf("%d",&n)!=EOF)
{
j=0;
while(n)
{
j++;
if(j%3==0||j%5==0)
n--;
}
printf("%d\n",j);


}
}
  
...全文
76 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
lwouyang 2009-03-08
  • 打赏
  • 举报
回复
#include"stdio.h"
int t[6]={15,3,5,6,9,10,12};
main()
{
int n;
while(scanf("%d",&n)!=EOF)
{
printf("%d\n",(n/6)*15 + t[n%6]);
}
}
neeestth 2009-03-08
  • 打赏
  • 举报
回复
汗,又没有什么难单词
zhan1094 2009-03-08
  • 打赏
  • 举报
回复
变回中文,速度会加十倍
WOBUGUAN 2009-03-08
  • 打赏
  • 举报
回复
很显然,大家都被你的英文吓跑了

69,371

社区成员

发帖
与我相关
我的任务
社区描述
C语言相关问题讨论
社区管理员
  • C语言
  • 花神庙码农
  • 架构师李肯
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧