Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

这是WA的代码,谁能帮看看,郁闷哦~

Posted by cangratul at 2007-04-28 20:08:04 on Problem 2984
In Reply To:help~ Posted by:cangratul at 2007-04-28 19:16:15
#include <stdio.h>
#include <string>
#define inf 8589934592
char buffer[10005],flag=1;
__int64 ans[1112],p,q;
int l,i,sum_1=0,h;
void main()
{
	scanf("%s",buffer);
	h=strlen(buffer);
	l=h/9;
	h%=9;
	for(p=0;p<h;p++)
	{
		ans[0]*=10;
		ans[0]+=buffer[p]-'0';
	}
	for(i=1;i<=l;i++)
	{
		q=9;
		while(q--)
		{
			ans[i]*=10;
			ans[i]+=buffer[p]-'0';
			p++;
		}
	}
	l++; h=0;
	while(flag)
	{
		if(ans[h]<inf) {q=ans[h]; h++;}
		else q=0;
		if(h==l) flag=0;
		for(i=h;i<l;i++)
		{
			ans[i]+=q*1000000000;
			q=ans[i]&(inf-1);
			ans[i]>>=33;
		}
		for(i=0;i<33;i++)
		{
			sum_1+=(1&q);
			q>>=1;
		}
	}
	memset(ans,0,sizeof(ans));
	ans[0]=1;
	l=sum_1/29;
	h=sum_1%29;
	while(l--)
	{ 
		for(q=i=0;ans[i]!=0||q!=0;i++)
		{
			ans[i]<<=29;
			p=ans[i]/1000000000;
			ans[i]%=1000000000;
			ans[i]+=q;
			q=p;
		}
	}
	for(q=i=0;ans[i]!=0||q!=0;i++)
	{
		ans[i]<<=h;
		p=ans[i]/1000000000;
		ans[i]%=1000000000;
		ans[i]+=q;
		q=p;
	}
	ans[0]--;
	l=i-1;
	printf("%I64d",ans[l]);
	for(i=l-1;i>=0;i--) printf("%.9I64d",ans[i]);
	putchar('\n');
}

Followed by:

Post your reply here:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator