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

让3的次数一直为0,用2的n次方来表示原数,老WA,那位仁兄可否帮忙看看?

Posted by qwynick at 2007-09-12 16:27:53 on Problem 3092
#include<stdio.h>
__int64 d[40],z[40];
int main()
{
//	freopen("wrw.txt","w",stdout);
	__int64 cs,c,i,n,top;
	d[0]=1;
	for(i=1;i<40;i++)
		d[i]=d[i-1]*2;
	scanf("%I64d",&cs);
	for(c=1;c<=cs;c++)
	{
		scanf("%I64d",&n);
		top=0;
		printf("%I64d",c);
		for(i=39;i>=0;i--)
			if(d[i]<=n)
			{
				n-=d[i];
				z[top++]=i;
			}
		printf(" %I64d",top);
		for(;top>0;)
			printf(" [%I64d,0]",z[--top]);
		printf("\n");
	}
	return 0;
}

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