__gcd编译错误
  • 板块灌水区
  • 楼主Loser_and_Joker
  • 当前回复5
  • 已保存回复5
  • 发布时间2021/9/3 22:28
  • 上次更新2023/11/4 08:03:43
查看原帖
__gcd编译错误
100709
Loser_and_Joker楼主2021/9/3 22:28
#include<cmath>
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
#define int long long
int m;
int a,b,c,d;
signed main()
{
    scanf("%lld/%lld",&a,&b);
    while(scanf("%lld/%lld",&c,&d)!=EOF)
    {
       	m=__gcd(b,d);
        a*=d/m;
        c*=b/m;
        a+=c;
        b*=d/m;
        m=__gcd(a,b);
        a/=m;
        b/=m;
    }
    if(b<0)
    {
        a=-a;
        b=-b;
    }
    if(b==1)
        printf("%lld\n",a);
    else
        printf("%lld/%lld\n",a,b);
    return 0;
}

为啥编译错误

2021/9/3 22:28
加载中...