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 talenth1 at 2011-01-10 22:29:20 on Problem 1019
先找找要到这么多个数字,序列里面最多要几位数,在找到是第几个序列,然后确定在这个序列里面那个位置是几位数,最后锁定位置上的数字。。。。写几个找找规律。。。
一下是code
/*
ID:   talenth1
PROG: p1019
LANG: C++
*/
#include<cstdio>
#include<iostream>
#include<cstdlib>
#include<cstring>
#include<cmath>
using namespace std;
int x,t;
int ld[]={0,45,9000,1386450,188019000,2147483647};
int lz[]={0,1,11,192,2893,38894};
int lr[]={0,9,180,2700,36000,4500000,54000000};
int lt[]={0,1,10,100,1000,10000,100000};
void work()
{
	int d,z,r,t,s,asi;
	for(d=1;;d++){//第d区 
		if(x>ld[d])x-=ld[d];
		else break;
		}
	for(z=1;;z++){//第z个 
		int ai=lz[d]+(z-1)*d;
		if(x>ai)x-=ai;
		else break;
		}
	for(r=1;;r++){//第r段 
		if(x>lr[r])x-=lr[r];
		else break;
		}
	t=x/r;
	asi=x%r;
	if(asi!=0)t++;
	if(!asi)asi=r;
	s=lt[r]+t-1;
	for(int i=1;i<=r-asi;i++)
		s/=10;
	printf("%d\n",s%10);
}
int main()
{
    freopen("p1019.in","r",stdin);
    freopen("p1019.out","w",stdout);       
    scanf("%d",&t);
    for(int i=1;i<=t;i++){
		scanf("%d",&x);
    	work();
		}
    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