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 frkstyc at 2006-01-25 18:43:13 on Problem 2748
In Reply To:用通项公式都超时,严重ft Posted by:BugKiller at 2006-01-25 18:17:28
> 估计是那些数学函数耗时比较多,以后还是用简单粗暴的方法算了……
> #include<iostream.h>
> #include<math.h>
> int main(){
> 	long cas,n,num;
> 	double temp;
> 	cin>>cas;
> 	while(cas>0){
> 		cas--;
> 		cin>>n;
> 		n=n%750000;
> 		temp=((5+sqrt(5))/(15+5*sqrt(5)))*pow((3+sqrt(5))/2,n)+(1+sqrt(5))/(2*sqrt(5))*pow((3-sqrt(5))/2,n);
> 		if(ceil(temp)-temp<0.4)
> 			num=ceil(temp);
> 		else
> 			num=floor(temp);
> 		cout<<num<<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