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

误差问题

Posted by KatrineYang at 2016-07-10 15:25:00 on Problem 1095 and last updated at 2016-07-10 15:25:14
In Reply To:16ms与0ms就是一个语句的差别? Posted by:gtzygtzy at 2009-08-03 15:00:39
忘了某个题,相同的代妈跑两遍一次0ms一次32ms,评测系统有误差的
> #include<iostream>
> using namespace std;
> int t[20];
> int sum[20];
> void init()
> {
> 	int i,j;
> 	t[0]=1;
> 	t[1]=1;
> 	for(i=2;i<=19;i++)
> 	{
> 		t[i]=0;
> 		for(j=0;j<i;j++) 
> 			t[i]+=t[j]*t[i-1-j];
> 	}
> 	sum[1]=1;
> 	//sum[0]=0;删了以后0MS,不删16MS
> 	for(i=2;i<=19;i++) sum[i]=sum[i-1]+t[i];
> }
> void printout(int x,int num)
> {
> 	if(x==1) {printf("X");return ;}
> 	if(x==2) 
> 	{
> 		if(num==1) printf("X(X)");
> 		else printf("(X)X");
> 		return ;
> 	}
> 	int i,re=0;
> 	for(i=0;i<x-1;i++)
> 	{
> 		if(re+t[i]*t[x-1-i]>=num) break;
> 		re+=t[i]*t[x-1-i];
> 	}
> 	if(i==0)
> 	{
> 		printf("X(");
> 		printout(x-1-i,num-re);
> 		printf(")");
> 		return ;
> 	}
> 	if(x-i-1==0)
> 	{
> 		printf("(");
> 		printout(i,num-re);
> 		printf(")X");
> 		return ;
> 	}
> 	int t1,t2;
> 	t1=(num-re-1)/t[x-1-i]+1;
> 	t2=(num-re)%t[x-1-i];
> 	printf("(");
> 	printout(i,t1);
> 	printf(")X(");
> 	printout(x-1-i,t2);
> 	printf(")");
> }
> int main()
> {
> 	int n,i;
> 	init();
> 	while(scanf("%d",&n))
> 	{
> 		if(n==0) break;
> 		for(i=1;;i++)if(sum[i]>=n) break;
> 		printout(i,n-sum[i-1]);
> 		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