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

why Wa???????!!!!!!!!!!!!!!!!! Help me !!!!

Posted by Snow_storm at 2010-02-21 02:28:41 on Problem 2282
通过了所有的样例
自己取的特例也都能过
#include<iostream>
#include<string.h>
using namespace std;
int f[10];
int weight,a,b;
void Find(int x)
{
	int i,one=x%10,high=x/10;
	if(x==a-1 || x==b)
		f[0]+=weight;
	x/=10;
	for(i=1;i<=one;i++)
		f[i]+=weight;
	while(high)
	{
		f[high%10]+=(one+1)*weight;
		high/=10;
	}
	for(i=0;i<10;i++)
		f[i]+=x*weight;
	weight*=10;
	if(x-1>0)
		Find(x-1);
}
int main()
{
	int i;
	while(1)
	{
		cin>>a>>b;
		if(!a && !b) break;
		if(a>b)
			swap(a,b);
		memset(f,0,sizeof(f));
		weight=-1;
		Find(a-1);
		weight=1;
		Find(b);
		for(i=0;i<9;i++)
			cout<<f[i]<<" ";
		cout<<f[9]<<endl;
	}
	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