其他分享
首页 > 其他分享> > poj 1953(斐波那契通项公式解法)

poj 1953(斐波那契通项公式解法)

作者:互联网

#include<iostream>
#include<cmath> 
#include<cstdio>
using namespace std;
int main(){
    int t,i,kase;
    long long n;
    double ans;
    scanf("%d",&t);
    kase = 1;
    while(kase<=t){
        scanf("%lld",&n);
        printf("Scenario #%d:\n",kase++);
        ans = (pow((1+sqrt(5.0))/2,(double)n+2)-pow((1-sqrt(5.0))/2,(double)n+2))/sqrt(5.0);
        printf("%.0llf\n\n",ans);
    }
    return 0;
}

 

标签:std,契通项,int,long,斐波,poj,kase,include
来源: https://www.cnblogs.com/stevenzrx/p/15119298.html