文学城论坛
+A-

回复:答案如下:共224位 (重贴,贴内不能连续有两个小于号 )

多多鸟 2009-05-12 06:01:36 ( reads)

答案是
第一位1 第五位8 第224位(最后一位)8

4999899999999999999999999999999999999999999999999999
9999999999999999999999999999999999999999999999999999
9999999999999999999999999999999999999999999999999999
9999999999999999999999999999999999999999999999999999
9999999999999998


程序如下
using namespace std;

#include

class bignum
{
public:
int ele[800];

bignum(){
for(int i=0; i }

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 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 for(int i=799; i >= 3; i--){
temp = b[i]*1000+b[i-1]*100+b[i-2]*10+b[i-3];

if(temp>=2009) {

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;
}


}
return temp;
}
};

int main(){
bignum a;

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


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

return 0;

}

跟帖(0)