Luogu brush questions C++ language |

Learn C++ from a baby! Record the questions in the process of Luogu C++ learning and test preparation, and record every moment.

Attached is a summary post: Luogu Brush Questions C++ Language | Summary


【Description】

After calculating the money, Yueluo Wuti thought: "You fuck me, (read in Hokkien below) Guili relies on cups and mothers, (read in English below) is Yiteyou!" So love and sorrow When the Great God asked how much it was, Yue Luo Wu Ti said a bunch of gibberish characters. The God of Love and Sorrow said: "Forget it, I just ask how much the price of the 1 nth  dish is?" Yueluo Wuti wrote:

Since the Great God of Love and Sorrow has learned programming, he found   the result of Fn in 11 minutes. Yueluo Wuti was taken aback by this. Can you learn from the God of Love and Sorrow to find  the value of Fn  ?

【enter】

One natural number  n per line .

【Output】

There is only one real number  Fn in one row , and two decimal places are reserved.

【Input sample】

6

【Example of output】

8.00

【Code Explanation】

#include <bits/stdc++.h>
#include <math.h>
using namespace std;

int main()
{
    int n;
    double t = sqrt(5), f;
    cin >> n;
    double a = (1+t)/2, b = (1-t)/2;
    f = (pow(a,n) - pow(b,n)) / t;
    printf("%.2f", f);
    return 0;
}

【operation result】

6
8.00

Guess you like

Origin blog.csdn.net/guolianggsta/article/details/132634985