| ||||||||||
| Online Judge | Problem Set | Authors | Online Contests | User | ||||||
|---|---|---|---|---|---|---|---|---|---|---|
| Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest | |||||||||
用通项公式都超时,严重ft估计是那些数学函数耗时比较多,以后还是用简单粗暴的方法算了……
#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: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator