if (k==0) printf("the %ld number is:%ld\n",y++,i++);
else if (k>0) i=i+k;
else i=i-k;
}
while(i<1111111111);
return 0;
}
long f(long m)
{
long s,sum,m_c,count;
sum=0;s=0;count=1;
do
{
m_c=m%10;
if(m_c==0)sum=sum+(m/10)*count;
else if(m_c==1)sum=sum+(m/10)*count+s+1;
else sum=sum+((m/10)+1)*count;
s=s+m_c*count;
count=count*10;
m=m/10;
}
while(m);
return sum;
}
复制代码
简单改了一下 递进方式 快是快了 不过得出的结果却漏了1,2个数 等高人讲讲
估计是递进的方法有问题 增加速度也是在这里如果直接I++要13M
Piii500 w2k cygwin
$ time ./a.exe
the 1 number is:1
the 2 number is:199981
the 3 number is:199982
the 4 number is:199983
the 5 number is:199984
the 6 number is:199985
the 7 number is:199986
the 8 number is:199987
the 9 number is:199988
the 10 number is:199989
the 11 number is:199990
the 12 number is:200000
the 13 number is:200001
the 14 number is:1599981
the 15 number is:1599982
the 16 number is:1599983
the 17 number is:1599984
the 18 number is:1599985
the 19 number is:1599986
the 20 number is:1599987
the 21 number is:1599988
the 22 number is:1599989
the 23 number is:1599990
the 24 number is:2600000
the 25 number is:2600001
the 26 number is:35000000
the 27 number is:35000001
the 28 number is:35199981
the 29 number is:35199982
the 30 number is:35199983
the 31 number is:35199984
the 32 number is:35199985
the 33 number is:35199986
the 34 number is:35199987
the 35 number is:35199988
the 36 number is:35199989
the 37 number is:35199990
the 38 number is:35200000
the 39 number is:35200001
the 40 number is:500000000
the 41 number is:500000001
the 42 number is:500199981
the 43 number is:500199982
the 44 number is:500199983
the 45 number is:500199984
the 46 number is:500199985
the 47 number is:500199986
the 48 number is:500199987
the 49 number is:500199988
the 50 number is:500199989
the 51 number is:500199990
the 52 number is:500200000
the 53 number is:500200001
the 54 number is:501599981
the 55 number is:501599982
the 56 number is:501599983
the 57 number is:501599984
the 58 number is:501599985
the 59 number is:501599986
the 60 number is:501599987
the 61 number is:501599988
the 62 number is:501599989
the 63 number is:501599990
the 64 number is:502600000
the 65 number is:502600001
the 66 number is:535000000
the 67 number is:535000001
the 68 number is:535199981
the 69 number is:535199982
the 70 number is:535199983
the 71 number is:535199984
the 72 number is:535199985
the 73 number is:535199986
the 74 number is:535199987
the 75 number is:535199988
the 76 number is:535199989
the 77 number is:535199990
the 78 number is:535200000
the 79 number is:535200001