QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#581119 | #9381. 502 Bad Gateway | hezlik | Compile Error | / | / | C++14 | 1.4kb | 2024-09-22 09:39:45 | 2024-09-22 09:39:45 |
Judging History
你现在查看的是最新测评结果
- [2024-09-24 14:55:37]
- hack成功,自动添加数据
- (/hack/886)
- [2024-09-22 09:39:45]
- 评测
- 测评结果:Compile Error
- 用时:0ms
- 内存:0kb
- [2024-09-22 09:39:45]
- 提交
answer
#include <bits/stdc++.h>
typedef long long int64;
struct frac{
int64 x,y;
frac():x(0),y(1){}
frac(int64 n):x(n),y(1){}
frac(int64 _x,int64 _y){
if (!_y)
assert(0);
if (!_x){
x=0;y=1;
}else{
bool neg=0;
if ((_x<0)!=(_y<0)) neg=1;
if (_x<0) _x=-_x;
if (_y<0) _y=-_y;
int64 _g=std::gcd(_x,_y);
x=_x/_g;
y=_y/_g;
if (neg) x=-x;
}
}
friend frac operator+(const frac &a,const frac &b){
return frac(a.x*b.y+b.x*a.y,a.y*b.y);
}
friend frac operator-(const frac &a,const frac &b){
return frac(a.x*b.y-b.x*a.y,a.y*b.y);
}
friend frac operator*(const frac &a,const frac &b){
return frac(a.x*b.x,a.y*b.y);
}
friend frac operator/(const frac &a,const frac &b){
return frac(a.x*b.y,a.y*b.x);
}
friend bool operator<(const frac &a,const frac &b){
return (__int128)a.x*b.y<(__int128)a.y*b.x;
}
friend bool operator>(const frac &a,const frac &b){
return (__int128)a.x*b.y>(__int128)a.y*b.x;
}
};
void work(){
int64 t;
std::cin>>t;
auto calc=[&](int64 c){
return frac(c-1,2)+frac(t,c);
};
int64 c=(int64)sqrt(2*t);
frac ans=calc(c);
if (c<t) ans=std::min(ans,calc(c+1));
std::cout<<ans.x<<' '<<ans.y<<'\n';
}
int main(){
std::ios::sync_with_stdio(0);
std::cin.tie(0);
int T=1;
std::cin>>T;
for (;T--;) work();
return 0;
}
详细
answer.code: In constructor ‘frac::frac(int64, int64)’: answer.code:22:21: error: ‘gcd’ is not a member of ‘std’ 22 | int64 _g=std::gcd(_x,_y); | ^~~