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 lihui_2008 at 2007-08-09 17:23:43 on Problem 3077
#include<stdio.h>
#include<string.h>
#include<math.h>
main()
{
	char a[20];
	int i,j,k,l,n;
	long total,sum1,sum2;
	scanf("%d",&n);
	for(i=1;i<=n;i++)
	{
		scanf("%s",a);
		l=strlen(a);
		k=l-1;
		sum1=0;
		sum2=1;
		total=0;
		if(l==1) 
			printf("%d\n",a[0]-48);
		else 
		{
			for(j=1;j<=k;j++)

			{     sum1=sum1+(a[j]-48)*pow(10,k-j);
			      sum2=sum2+4*pow(10,k-j);
				  if(sum1>=sum2) 
					  a[0]=a[0]+1;
			}
			total=total+(a[0]-48)*pow(10,l-1);
			printf("%ld\n",total);
		}
	}
}


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