答案如下:共224位

来源: 多多鸟 2009-05-12 05:55:33 [] [旧帖] [给我悄悄话] 本文已被阅读: 次 (2190 bytes)
本文内容已被 [ 多多鸟 ] 在 2009-05-12 06:10:53 编辑过。如有问题,请报告版主或论坛管理删除.
答案是
第一位1 第五位8 第224位(最后一位)8 其余位皆为9

4999899999999999999999999999999999999999999999999999
9999999999999999999999999999999999999999999999999999
9999999999999999999999999999999999999999999999999999
9999999999999999999999999999999999999999999999999999
9999999999999998


程序如下
using namespace std;

#include

class bignum
{
public:
int ele[800];

bignum(){
for(int i=0; i<800; i++)ele[i]=0;
}

void update(){
int ip =0;
int i=0;

while(ip==0){
if(ele[i] > ele[i+1]){
ele[i] --;
ele[i+1] ++;
ip =1;
}
i++;
}
}


int bitsum(){
int sum=0;
for(int i=0; i<800; i++)sum += ele[i];
return sum;
}

public:
void out(){
int ip =799;
while(ele[ip]==0)ip--;
for(int i=ip; i>=0; i--)cout< cout< }

int mod2009(){
int b[800];
int temp;
for(int i=0; i<800; i++) b[i]=ele[i];
for(int i=799; i >= 3; i--){
temp = b[i]*1000+b[i-1]*100+b[i-2]*10+b[i-3];
// if(temp>0)cout< // < if(temp>=2009) {
// cout<<"in mod2009: "<< temp< temp = temp % 2009;
b[i-3]= temp %10;
b[i-2]= (temp % 100)/10;
b[i-1]= (temp)/100;
}
else {
b[i-1] += b[i]*10;
b[i]=0;
}
// if(temp>0)cout< // <
}
return temp;
}
};

int main(){
bignum a;

// set up the smallest number with bitsum of 2009
for(int i=0; i<223; i++) a.ele[i]=9;
a.ele[223]=2;


a.out();
cout<
int kk= a.mod2009();
while(kk != 0){ a.update();
a.out();
kk= a.mod2009();
cout< }

return 0;

}

所有跟帖: 

回复:答案如下:共224位 (重贴,贴内不能连续有两个小于号 ) -多多鸟- 给 多多鸟 发送悄悄话 (1914 bytes) () 05/12/2009 postreply 06:01:36

这个大概是第二小的,还有一个更小 -康MM- 给 康MM 发送悄悄话 康MM 的博客首页 (0 bytes) () 05/12/2009 postreply 06:07:42

我的程序错了。这个是第3小的。前40个如下。 -多多鸟- 给 多多鸟 发送悄悄话 (4638 bytes) () 05/14/2009 postreply 05:19:11

请您先登陆,再发跟帖!

发现Adblock插件

如要继续浏览
请支持本站 请务必在本站关闭/移除任何Adblock

关闭Adblock后 请点击

请参考如何关闭Adblock/Adblock plus

安装Adblock plus用户请点击浏览器图标
选择“Disable on www.wenxuecity.com”

安装Adblock用户请点击图标
选择“don't run on pages on this domain”