QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#584377 | #9381. 502 Bad Gateway | 2497201210 | WA | 423ms | 3620kb | C++14 | 721b | 2024-09-23 13:29:29 | 2024-09-23 13:29:29 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
#define endl '\n'
const int N=1e6+10;
const int P=998244353;
int qim(int a,int b){
int res=1;
while(b){
if(b&1)res=(res*a)%P;
b/=2;
a=(a*a)%P;
}
return res;
}
inline int gcd(int a,int b){
return b?gcd(b,a%b):a;
}
inline void solve(){
int n;cin>>n;
int id;double res=1e18;
for(int i=max(0,(int)sqrt(2*n)-1);i<=min(n,(int)sqrt(2*n)+1);i++){
long double now=i;
now=(long double)1.0*n/now+now/2;
if(now<res){
res=now;id=i;
}
}
int q=2*n+id*id-id;
int p=2*id;
int gg=gcd(q,p);
q/=gg;
p/=gg;
cout<<q<<' '<<p<<endl;
}
signed main(){
cin.tie(0);cout.tie(0);
int t;t=1;cin>>t;
while(t--){
solve();
}
}
詳細信息
Test #1:
score: 100
Accepted
time: 0ms
memory: 3620kb
input:
3 1 2 3
output:
1 1 3 2 2 1
result:
ok 3 lines
Test #2:
score: -100
Wrong Answer
time: 423ms
memory: 3564kb
input:
1000000 1 1000000000 1 1 1000000000 1 1000000000 1 1 1 1000000000 1 1 1000000000 1 1000000000 1000000000 1 1000000000 1 1 1000000000 1 1000000000 1000000000 1 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1 1 1000000000 1 1000000000 1000000000 1000000000 1000000000 1 1 1 10000000...
output:
1 1 147522088 -44721 1 1 1 1 147522088 -44721 1 1 147522088 -44721 1 1 1 1 1 1 147522088 -44721 1 1 1 1 147522088 -44721 1 1 147522088 -44721 147522088 -44721 1 1 147522088 -44721 1 1 1 1 147522088 -44721 1 1 147522088 -44721 147522088 -44721 1 1 147522088 -44721 147522088 -44721 147522088 -44721 14...
result:
wrong answer 2nd lines differ - expected: '1999961560 44721', found: '147522088 -44721'