首页 > 其他 > 详细

C Sleepy Kaguya

时间:2019-01-06 19:39:23      阅读:169      评论:0      收藏:0      [点我收藏+]

链接:https://ac.nowcoder.com/acm/contest/338/C
来源:牛客网

题目描述

Houraisan☆Kaguya is the princess who lives in Literally House of Eternity. However, she is very playful and often stays up late. This morning, her tutor, Eirin Yagokoro was going to teach her some knowledge about the Fibonacci sequence. Unfortunately, the poor princess was so sleepy in class that she fell asleep. Angry Eirin asked her to complete the following task:

This sequence can be described by following equations:
    1.F[1]=F[2]=1
    2.F[n]=F[n-1]+F[n-2]  (n>2)

Now, Kaguya is required to calculate F[k+1]*F[k+1]-F[k]*F[k+2] for each integer k that does not exceed 10^18.
Kaguya is so pathetic. You have an obligation to help her.

(I love Houraisan Kaguya forever!!!)
技术分享图片
image from pixiv,id=51208622

输入描述:

Input
Only one integer k.

输出描述:

Output
Only one integer as the result which is equal to F[k+1]*F[k+1]-F[k]*F[k+2].
示例1

输入

复制
2

输出

复制
1

说明

F[2]=1,F[3]=2,F[4]=3

2*2-1*3=1

备注:

0 < k ≤ 1^18
If necessary, please use %I64d instead of %lld when you use "scanf", or just use "cin" to get the cases.


The online judge of HNU has the above feature, thank you for your cooperation.

找规律 -1 1
技术分享图片
#include<stdio.h>
#include<iostream>
using namespace std;
int main()
{
    unsigned long long int n;
    cin >> n;
    if(n&1)
        cout<<"-1"<<"\n";
    else
        cout<<"1"<<"\n";
}
View Code

 

C Sleepy Kaguya

原文:https://www.cnblogs.com/DWVictor/p/10229982.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!