发现n无比大,肯定是一步得答案的那种,考虑化简
发现最后n很大很大精度就会掉,直接输出2即可
code by wzxbever:
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
double pow(int a,int b){
double sum=1;
while(b){
if(b&1)sum*=a;
b>>=1;a*=a;
}
return sum;
}
int gcd(int n,int m){
if(m==0)return n;
else return gcd(m,n%m);
}
int main(){
int sum=0,n;
double a[1010];a[1]=1;a[2]=1;
for(int i=3;i<=83;i++)
a[i]=a[i-1]+a[i-2];
scanf("%d",&n);
// printf("a[n+3]=%llf\n",a[83]);
double ans;
if(n<=31){
ans=a[n+3]/pow(2,n);
printf("%.9f\n",2-ans);
}else if(n<=62){
ans=a[n+3]/pow(2,31);
ans/=pow(2,n-31);
printf("%.9f\n",2-ans);
}else if(n<=83){
ans=a[n+3]/pow(2,31);
ans/=pow(2,31);
ans/=(2,n-62);
printf("%.9f\n",2-ans);
}
else printf("2\n");
return 0;
}