But also a Fibonacci number (count garlic off)

 There was another conveyance Fibonacci number column: F0 = 7, F1 = 11, Fn = Fn-1 + Fn-2 (n≥2).

Input Format

Input data composed of multiple rows, each row is an integer n (n <10 ^ 6).

Output Format

If the Fn be divisible by 33, then print a line "yes", otherwise, print one line "no".

#include <iostream>

using namespace std;


long long F[1000001];

void Fib() {
    F[0] = 7;
    F[1] = 11;
    for (int i = 2; i <= 1000000; i++) {
        F[i] = (F[i - 1] + F[i - 2]) % 3 ;
    }
}

int main() {
    int n;
    Fib();
    while (cin >> n) {
        if (F[n] % 3 == 0) cout << "yes" << endl;
        else cout << "no" << endl;
    }
    return 0;
}

 

Published 98 original articles · won praise 5 · views 10000 +

Guess you like

Origin blog.csdn.net/chengsilin666/article/details/104084248