zoukankan      html  css  js  c++  java
  • 洛谷P1720 月落乌啼算钱

    目背景

    (本道题目木有以藏歌曲……不用猜了……)

    《爱与愁的故事第一弹·heartache》最终章。

    吃完pizza,月落乌啼知道超出自己的预算了。为了不在爱与愁大神面前献丑,只好还是硬着头皮去算钱……

    题目描述

    算完钱后,月落乌啼想着:“你TMD坑我,(以下用闽南语读)归粒靠杯靠亩诶,(以下用英读)是伊特游!”于是当爱与愁大神问多少钱时,月落乌啼说了一堆乱码。爱与愁大神说:“算了算了,我只问第n样菜价格多少?”月落乌啼写出了:。由于爱与愁大神学过编程,于是就用1分钟的时间求出了Fn的结果。月落乌啼为此大吃一惊。你能学学爱与愁大神求出Fn的值吗?

    输入输出格式

    输入格式:

    只有1行:n

    输出格式:

    只有1行:Fn,保留两位小数。

    输入输出样例

    输入样例#1:
    6
    输出样例#1:
    8.00

    说明

    简单死了……

    所有数据:n<=48

    水到不好意思发博客。。。。

     1 #include<iostream>
     2 #include<cstdio>
     3 #include<cstring>
     4 #include<cmath>
     5 #define ls k<<1
     6 #define rs k<<1|1
     7 using namespace std;
     8 const int MAXN=400400;
     9 inline void read(int &n)
    10 {
    11     char c=getchar();n=0;bool flag=0;
    12     while(c<'0'||c>'9')    c=='-'?flag=1,c=getchar():c=getchar();
    13     while(c>='0'&&c<='9')    n=n*10+c-48,c=getchar();flag==1?n=-n:n=n;
    14 }
    15 
    16 int main()
    17 {
    18     int n;
    19     read(n);
    20     double a=pow( (1+sqrt(5))/2,n ) - pow( (1-sqrt(5))/2,n );
    21     printf("%.2lf",a/(sqrt(5)));
    22     return 0;
    23 }
  • 相关阅读:
    12月4日
    12月3日
    12月2日
    12月1日
    11月30日
    11月29日
    11月28日
    11月27日
    jquery mobile-按钮控件
    ap web
  • 原文地址:https://www.cnblogs.com/zwfymqz/p/7701707.html
Copyright © 2011-2022 走看看