[qbxt考试Day5.T1]切蛋糕

来源:互联网 发布:淘宝商城女装韩版 编辑:程序博客网 时间:2024/05/16 14:48

这里写图片描述

码住,改天写题解……

#include<iostream>#include<cstdio>#include<algorithm>#define LL long longusing namespace std;const int MAXN = 1000 + 50;LL n,m,k,f[MAXN];LL ans;int calc(int p,int q){    if(p == q)return p;    if(p < q)swap(p,q);    //printf("p=%d q=%d\n",p,q);    return calc(q,p - q);}void check(LL x,LL y){    for(int i = 0;i < 70;i ++)    {        if(f[i] * x % f[i + 1] == 0)            ans = max(ans,(x - calc(x,f[i] * x / f[i + 1]))* y);    }}int main(){    freopen("cut.in", "r", stdin);    freopen("cut.out", "w", stdout);    scanf("%d%d",&n,&m);    f[0] = 1;f[1] = 1;    for(int i = 1;i <= 70;i ++)        f[i] = f[i - 1] + f[i - 2];    check(n,m);check(m,n);    printf("%lld",ans);    return 0;}