QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#582649#9381. 502 Bad GatewaycyanacCompile Error//C++14748b2024-09-22 17:04:232024-09-22 17:04:27

Judging History

你现在查看的是最新测评结果

  • [2024-09-24 14:55:37]
  • hack成功,自动添加数据
  • (/hack/886)
  • [2024-09-22 17:04:27]
  • 评测
  • [2024-09-22 17:04:23]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
#define int long long
void solve()
{
    int n;
    cin>>n;
    int t1=ceil(sqrt(n));
    int t2=floor(sqrt(n));
    int res1=(t1-1)*t1;
    int res2=n*2;
    res1+=res2;
    int k=gcd(res1,2*t1);
    int ansx=res1/k;
    int ansy=2*t1/k;
    res1=(t2-1)*t2;
    res2=n*2;
    res1+=res2;
    k=gcd(res1,2*t2);
    int ansxx=res1/k;
    int ansyy=2*t2/k;
    if(double(ansx)/double(ansy)>double(ansxx)/double(ansyy))
    {
        cout<<ansxx<<' '<<ansyy<<endl;
    }
    else cout<<ansx<<' '<<ansy<<endl;

}
signed main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int T;
    cin>>T;
    while(T--)
    {
        solve();
    }


}

Details

answer.code: In function ‘void solve()’:
answer.code:13:11: error: ‘gcd’ was not declared in this scope
   13 |     int k=gcd(res1,2*t1);
      |           ^~~