关于斐波那契数列的一些恒等式 模板 牛客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