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

为什么会Runtime Error?数据都行.

Posted by 19910517 at 2009-05-13 16:50:20 on Problem 1019
#include <iostream>
#include <math.h>
using namespace std;
int b1[100000];
int b2[10000000];
void setb1(int b1[],int n)
{
	int i,first1,first2,count1=0;
	b1[0]=0;
	
	for(i=1;i<n;i++)
	{
		if(i==pow(double(10),count1))
		{
			if(i==0)
			{
				first1=0;
				first2=0;
			}
			else
			{
				first1=b1[i-1];
				first2=i-1;
			}
			count1++;
		}
		b1[i]=first1+count1*(i-first2);
	}
}
void setb2(int b2[],int n)
{
	int i;
	b2[0]=0;
	for(i=1;i<n;i++)
	{
		b2[i]=b2[i-1]+b1[i];
	}
}

int main()
{
	int i,j,n,m;
	setb1(b1,100000);
	setb2(b2,10000000);
	
	cin>>n;

	for(i=0;i<n;i++)
	{
		cin>>m;

		for(j=0;;j++)
		{
			if(m>b2[j] && m<=b2[j+1])
			{
				m-=b2[j];
				break;
			}
		}
		for(j=0;;j++)
		{
			if(m>b1[j] && m<=b1[j+1])
			{
				m-=b1[j];
				break;
			}
		}
		j++;
		for(int k=0;k<(b1[j]-b1[j-1]-m);k++)
		{
			j/=10;
		}
		cout<<j%10<<endl;
	}			
	return 1;
}

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