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呢?真奇怪!我没用到stack啊。怎么会是stack overflow呢?请大牛看看。

Posted by 2006011312 at 2007-08-17 00:44:42 on Problem 1019
#include<iostream>
using namespace std;
int main()
{

	int t=0,m=0,j=0,i=0,k=0;	
		int number[113512]={0},weishu_1[113513]={0},weishu_2[113513]={0};
	for(i=1;i<10;i++)
		weishu_2[i]=1;
	for(i=10;i<100;i++)

		weishu_2[i]=2;
	for(i=100;i<1000;i++)
		weishu_2[i]=3;
	for(i=1000;i<10000;i++)
		weishu_2[i]=4;
	for(i=10000;i<100000;i++)
		weishu_2[i]=5;
	for(i=100000;i<113512;i++)
		weishu_2[i]=6;
	cout<<1<<endl;

	for(i=1;i<=113511;i++)
	{
		weishu_1[i]=weishu_1[i-1]+weishu_2[i];
	}
	for(i=1;i<=113511;i++)
	{
		number[i]=number[i-1]+weishu_1[i];
	}
	cin>>t;
	for(i=1;i<=t;i++)
	{
		cin>>m;
		for(j=0;j<=113510;j++)		
			if(m>number[j]&&m<=number[j+1])			
				m-=number[j];
		if(m>number[113511])
			m-=number[113511];
				for(k=1;k<=113512;k++)
					if(m>weishu_1[k]&&m<=weishu_1[k+1])
					{
						m-=weishu_1[k];
						if(m==weishu_1[k+1])
							cout<<(k+1)%10<<endl;
						else
							cout<<((k+1)/(10*(weishu_2[k+1]-m)))%10<<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