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

Re:所有测试数据都通过,却无法提交,郁闷ing

Posted by hellofalcon at 2006-07-05 19:13:47 on Problem 1001
In Reply To:所有测试数据都通过,却无法提交,郁闷ing Posted by:hellofalcon at 2006-07-05 17:39:24
> 大家帮忙看看哦,我是昨天刚开始来做题的,不是很清楚这个答题的规则
> 
> 我的测试结果:
> falcon@falcon:~/program/c/code/acm$ time ./1001 <a
> 
> 548815620517731830194541.899025343415715973535967221869852721
> .00000005148554641076956121994511276767154838481760200726351203835429763013462401
> 43992025569.928573701266488041146654993318703707511666295476720493953024
> 29448126.764121021618164430206909037173276672
> 90429072743629540498.107596019456651774561044010001
> 1.126825030131969720661201
> 
> real    0m0.014s
> user    0m0.011s
> sys     0m0.003s
> 
> 结果对着,时间好象也不多亚?
> 请教高手
> 
> Wrong Answer



干脆把代码贴上来,希望大家帮个忙阿/

#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#define Len 200
char r[2*Len-1];

void lnmp(char *cs,char *bcs)
{
char cjr[Len][Len][2];
int i,j,k,l,cslen,bcslen,rlen,jw=0,temp,out=0;

cslen=strlen(cs);
bcslen=strlen(bcs);
rlen=cslen+bcslen-1;

for(i=cslen-1;i>=0;i--)
for(j=bcslen-1;j>=0;j--)
{
	temp=(cs[i]-'0')*(bcs[j]-'0');
	cjr[j][i][0]=temp/10;
	cjr[j][i][1]=temp%10;
}
for(l=rlen;l>=0;l--)
{
	temp=jw;
	for(i=cslen-1;i>=0;i--)
	for(j=bcslen-1;j>=0;j--)
	for(k=1;k>=0;k--)
	if(l==i+j+k) temp=temp+cjr[j][i][k];
	jw=temp/10;
	r[l]=temp%10+'0';
}
for(l=0;l<rlen;l++) if(r[l]!='0') break;
if(l) for(i=l;i<=rlen+1;i++) r[i-l]=r[i];
}

int main()
{
char R[Len];
int N;
int i,j,k,xsdws,temp,flag;

while(scanf("%s %d",R,&N)!=EOF)
{
i=1,flag=0;
temp=strlen(r);
for(i=0;i<temp;i++) r[i]='\0';

temp=strlen(R);
for(i=0;i<temp;i++)
if(R[i]=='.') break;
if(i!=temp)
{
	flag=1;
	xsdws=(temp-i-1)*N; 
	for(j=i;j<=temp;j++)
	R[j]=R[j+1];
}

for(i=0;i<temp;i++) if(R[i]!='0') break;
if(i) for(j=i;j<=temp;j++) R[j-i]=R[j];

strcpy(r,R);
for(i=1;i<N;i++)
lnmp(r,R);

temp=strlen(r);
if(!flag)
{
	for(j=0;j<temp;j++)
	putchar(r[j]);
}
else
{	
	i=temp-xsdws;
	if(temp>xsdws)
	{
		i=temp-xsdws;
		for(j=0;j<i;j++)	putchar(r[j]);
		putchar('.');
		for(k=temp-1;k>=0;k--)	if(r[k]!='0') break;
		for(j=i;j<k+1;j++)	putchar(r[j]);
	}
	else
	{
		i=xsdws-temp;
		putchar('.');
		for(j=0;j<i;j++)	putchar('0');
		for(j=0;j<temp;j++)	putchar(r[j]);	
	}
}
putchar('\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