C++48分,求助
查看原帖
C++48分,求助
780141
UNNN楼主2023/1/18 22:05

直接套斐波那契通项公式应该不要紧吧QWQ

#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
using namespace std;
typedef long long ll;
const ll MOD = 1e8;
ll n, m, x, c, ans;
int main()
{
   scanf("%lld%lld", &n, &m);
   x = __gcd(n, m);
   c = 1 / sqrt(5) * (pow((1 + sqrt(5)) / 2, x) - pow((1 - sqrt(5)) / 2, x));
   ans = c % MOD;
   printf("%lld", ans);
   return 0;
}

2023/1/18 22:05
加载中...