关于斐波那契数列的一些恒等式 模板 牛客OI测试赛 A 斐波拉契

 

牛客A 斐波拉契

链接:https://www.nowcoder.com/acm/contest/181/A
来源:牛客网

设f[i]表示斐波那契数论的第i项
f[1]=1,f[2] =1,f[i] = f[i - 1] + f[i - 2]
给定一个n


输入描述:

一个整数n

输出描述:

一个整数,表示答案

示例1

输入

复制
4

输出

复制
1

备注:

分析:第六个恒等式

AC代码:

#include <map>
#include <set>
#include <stack>
#include <cmath>
#include <queue>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <algorithm>
#define ls (r<<1)
#define rs (r<<1|1)
#define debug(a) cout << #a << " " << a << endl
using namespace std;
typedef long long ll;
const ll maxn = 1e3 + 10;
const double eps = 1e-8;
const ll mod = 1e9 + 7;
const ll inf = 1e9;
const double pi = acos(-1.0);
int main() {
    std::ios::sync_with_stdio(false);
    string s;
    cin >> s;
    ll n = s[s.length()-1] - '0';
    if(n&1) {
        cout << -1 << endl;
    } else {
        cout << 1 << endl;
    }
    return 0;
}

  

转载于:https://www.cnblogs.com/l609929321/p/9559119.html

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值