南阳理工ACM954--N!

http://acm.nyist.net/JudgeOnline/problem.php?pid=954

循环的可怕之处!!

所有的测试数据结果完全一样。只是超时!!TimeLimitExceeded

#include<stdio.h>
#include<stdlib.h>
#include<iostream>
using namespace std;
void init()
{
freopen("a.in","r",stdin);
freopen("a.out","w",stdout);
}
int main()
{
int n;
int i,k;
//init();
while (cin>>n)
{
k = ;
for(i = ;i<=n;i*=)
{
k += n/i;
}
cout<<k<<endl;
}
return ;
} /*
#include<stdio.h>
#include<stdlib.h>
#include<iostream>
using namespace std;
int main()
{
int n;
int i,k,j;
while (scanf("%d",&n)!=EOF)
{
k = 1;
for(i = 1;i<=n;i++)
{
if (0==i%2)
{
k++;
j = i/2;
while (j!=0)
{
if (0==j%2)
{
k++;
j = j/2;
}
else
break;
}
}
}
printf("%d\n",k);
}
return 0;
}
*/
上一篇:南阳理工ACM1076--方案数量


下一篇:GoldenGate实时投递数据到大数据平台(1)-MongoDB