华华对月月的忠诚
华华对月月的忠诚
http://www.nowcoder.com/questionTerminal/647d45470c63407db0152d3ebb407fa3
想一下求最大公约数的辗转相除法,如果用在斐波那契数列上,就会得到,直接求前两个数字就行了
# include <cstdio> # include <cstring> # include <cctype> # include <cmath> # include <cstdlib> # include <climits> # include <iostream> # include <iomanip> # include <set> # include <map> # include <vector> # include <stack> # include <queue> # include <algorithm> using namespace std; const int debug = 1; const int size = 5000 + 10; const int INF = INT_MAX>>1; typedef long long ll; int main() { // std::ios::sync_with_stdio(false);cin.tie(0); ll a, b, n; cin >> a >> b >> n; cout << __gcd(a, b) << endl; return 0; }