全 WA 求调 https://www.luogu.com.cn/record/197323143
#include <bits/stdc++.h>
using namespace std;
#define pass
#define BREAK Sleep(100)
#define WAIT Sleep(200)
#define SLEEP Sleep(500)
struct FenShu
{
int son,mum;
// Found
FenShu() :
son(0),
mum(1)
{
return pass;
}
FenShu(const int _num) :
son(_num),
mum(1)
{
return pass;
}
FenShu(const double _num) :
son((int)(_num*1e10)/__gcd((int)(_num*1e10),(int)(1e10))),
mum((int)(1e10)/__gcd((int)(_num*1e10),(int)(1e10)))
{
return pass;
}
FenShu(const int _son,const int _mum) :
son(_son),
mum(_mum)
{
Error();
return pass;
}
// Basic
void Error(int err=0) const
{
if(err == 1 || mum == 0)
cout << " [ERROR] 分母为零!\n",err = 1;
else return pass;
exit(-err);
}
void scan()
{
std::scanf("%d%d",&son,&mum);
return pass;
}
void scanf()
{
double num;
std::scanf("%lf",&num);
son = (long long)(num*1e15)/__gcd((long long)(num*1e15),(long long)(1e15));
mum = (long long)(1e15)/__gcd((long long)(num*1e15),(long long)(1e15));
return pass;
}
void print() const
{
std::printf("%d/%d",son,mum);
return pass;
}
void printf(const int BaoLiu = -1) const
{
if(BaoLiu == -1)
std::cout << son*1.0/mum;
else std::printf(("%" + to_string(BaoLiu) + "lf").c_str(),son*1.0/mum);
return pass;
}
// If of Two-X
bool operator == (const FenShu b) const
{
return (son * b.mum / __gcd(mum,b.mum) == b.son * mum / __gcd(mum,b.mum));
}
bool operator < (const FenShu b) const
{
return (son * b.mum / __gcd(mum,b.mum) < b.son * mum / __gcd(mum,b.mum));
}
bool operator > (const FenShu b) const
{
return (son * b.mum / __gcd(mum,b.mum) > b.son * mum / __gcd(mum,b.mum));
}
bool operator <= (const FenShu b) const
{
return (son * b.mum / __gcd(mum,b.mum) <= b.son * mum / __gcd(mum,b.mum));
}
bool operator >= (const FenShu b) const
{
return (son * b.mum / __gcd(mum,b.mum) >= b.son * mum / __gcd(mum,b.mum));
}
// Operator of One-X
FenShu YueFen() const
{
FenShu c;
c.son = son / __gcd(son,mum);
c.mum = mum / __gcd(son,mum);
return c;
}
FenShu operator ~ () const
{
FenShu c;
c.son = son / __gcd(son,mum);
c.mum = mum / __gcd(son,mum);
return c;
}
FenShu DaoShu() const
{
FenShu c;
c.son = mum;
c.mum = son;
c.Error();
return c;
}
FenShu operator ! () const
{
FenShu c;
c.son = mum;
c.mum = son;
c.Error();
return c;
}
// Operator of Two-X
FenShu operator + (const FenShu b) const
{
FenShu c;
c.son = son * b.mum / __gcd(mum,b.mum) + b.son * mum / __gcd(mum,b.mum);
c.mum = mum * b.mum / __gcd(mum,b.mum);
return c;
}
FenShu operator - (const FenShu b) const
{
FenShu c;
c.son = son * b.mum / __gcd(mum,b.mum) - b.son * mum / __gcd(mum,b.mum);
c.mum = mum * b.mum / __gcd(mum,b.mum);
return c;
}
FenShu operator * (const FenShu b) const
{
FenShu c;
c.son = son * b.son;
c.mum = mum * b.mum;
c = ~c;
return c;
}
FenShu operator / (const FenShu b) const
{
FenShu c;
c.son = son * b.mum;
c.mum = mum * b.son;
c.Error();
c = ~c;
return c;
}
};
// FenShu to Else Type
double FStof(const FenShu fs)
{
return fs.son*1.0/fs.mum;
}
int FStoi(const FenShu fs)
{
return fs.son/fs.mum;
}
FenShu to_FS(const double num)
{
FenShu fs(num);
return fs;
}
FenShu to_FS(const int num)
{
FenShu fs(num);
return fs;
}
FenShu a,b;
int main()
{
a.scanf(); b.scanf();
(a - to_FS(FStoi(a/b)) * b).printf(); cout << "\n";
return 0;
}