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????

Posted by lidongliang123456 at 2006-10-10 14:43:30 on Problem 1863
#include<iostream.h>
int main()
{
	int a[493]={0};
	int k=1;
	for(long i=1;i<=200;i++)
	{
		if(i<10)
		{a[k]=i;k++;}
		else if(i>=10&&i<100)
		{
			a[k]=i/10;
			k++;
			a[k]=i-(i/10)*10;
			k++;
		}
		else
		{
			a[k]=i/100;
	        k++;
			a[k]=(i-(i/100)*100)/10;
			k++;
			a[k]=i-a[k-1]*10-a[k-2]*100;
			k++;
		}
	}

	int n;
	cin>>n;
	k=1;
//	for(i=1;i<=492;i++)
//		cout<<a[i]<<" ";

	
	for(i=1;i<=490;i++)
	{
		if(n<10&&(n==a[i]))
		{cout<<i<<endl;break;}
		else if(n<100&&(n==a[i]*10+a[i+1]))
			{cout<<i<<endl;break;}
			else
		if(n==a[i]*100+a[i+1]*10+a[i+2])
		{cout<<i<<endl;break;}
	}
	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