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

终于a了,讲下思路

Posted by lijingwei at 2011-08-03 22:18:03 on Problem 2539 and last updated at 2011-08-03 22:18:31
In Reply To:知道等比序列和再怎么办?求助!!!!!!!!!!!!!! Posted by:lijingwei at 2011-08-03 21:27:50
我不知道为什么。。。就一个一个加,就200-过去了。。。直接用那个公式,一直tle
核心代码
if((double)(a-b)*Math.log10(tt)>=(double)100)//如果最后一项都有100位了
        		{
        			System.out.println("("+t+"^"+a+"-1)/("+t+"^"+b+"-1) is not an integer with less than 100 digits.");            		
        			continue;
        		}


//之前这里写的就是那个直接算那个(t^a-1)/(t^b-1),我想着前面的剪枝,应该能处理那些特别大。显然超过100位的,但是一直tle,改成了下面的一个一个加,就过去了
        		temp=BigInteger.valueOf(0);
        		for(i=0;i<a/b;i++)//逆序更好
        		{
        			temp=temp.add(pow(t,i*b));//自己写二分
        			if(temp.compareTo(max)>=0)//max就是10^100
        				break;
        		}
就过了。懂的人讲下理由,(t^a-1)/(t^b-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