QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#582998#9381. 502 Bad GatewaymosuoWA 126ms3736kbC++201.8kb2024-09-22 17:56:492024-09-22 17:57:01

Judging History

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

  • [2024-09-24 14:55:37]
  • hack成功,自动添加数据
  • (/hack/886)
  • [2024-09-22 17:57:01]
  • 评测
  • 测评结果:WA
  • 用时:126ms
  • 内存:3736kb
  • [2024-09-22 17:56:49]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;

#define int long long
#define fi first
#define se second
#define i128 __int128
typedef pair<int,int>PII;
typedef pair<int,char>PIC;
typedef pair<int,PII>PIII;

const int N=300010,mod=1000000007;

int dx[4]={0,0,1,-1};
int dy[4]={1,-1,0,0};

int gcd(int a,int b){
    return b?gcd(b,a%b):a;
}
int lcm(int a, int b) {
    return a * b / gcd(a, b);
}
int qmi(int x,int k,int q ){
    int cnt=x;
    int res=1;
    while(k){
        if(k&1)res=res*cnt%q;
        k>>=1;
        cnt=cnt*cnt%q;
    }
    return res;
}
int fact[N], infact[N];

void init_C(){
    fact[0]=infact[0]=1;
    for (int i = 1; i < N; i++){
        fact[i]=fact[i-1]*i%mod;
        infact[i]=infact[i-1]*qmi(i,mod-2,mod)%mod;
    }
}

int get_C(int a, int b){
    int res = (fact[a] * infact[b] % mod * infact[a - b] % mod) % mod;
    return res;
}


void solve(){
    int n;
    cin >> n;
    int l = sqrt(2 * n);
    int r = ceil(sqrt(2 * n));
    if(n==1){
        cout << "1 1\n";
        return;
    }

    double r1 = (1.0 + l) * l / 2.0 + 1.0 * (n - l) * (l+1);
    double r2 = (1.0 + r) * r / 2.0 + 1.0 * (n - r) * (r+1);
    
    if(r1<r2){
        int u = 0, d = 0;
        u = (1 + l) * l + 2 * (n - l) * (l + 1);
        d = 2 * n;
        int g = gcd(u, d);
        u /= g;
        d /= g;
        cout << u << ' ' << d << '\n';
    }
    else {
        int u = 0, d = 0;
        u = (1 + r) * r + 2 * (n - r) * (r + 1);
        d = 2 * n;
        int g = gcd(u, d);
        u /= g;
        d /= g;
        cout << u << ' ' << d << '\n';
    }
}


signed main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    

    int t;cin>>t;
    while(t--)
        solve();
    
    return 0;
}

详细

Test #1:

score: 100
Accepted
time: 0ms
memory: 3736kb

input:

3
1
2
3

output:

1 1
3 2
2 1

result:

ok 3 lines

Test #2:

score: -100
Wrong Answer
time: 126ms
memory: 3684kb

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
44720999993719 1000000000
1 1
1 1
44720999993719 1000000000
1 1
44720999993719 1000000000
1 1
1 1
1 1
44720999993719 1000000000
1 1
1 1
44720999993719 1000000000
1 1
44720999993719 1000000000
44720999993719 1000000000
1 1
44720999993719 1000000000
1 1
1 1
44720999993719 1000000000
1 1
4472099999...

result:

wrong answer 2nd lines differ - expected: '1999961560 44721', found: '44720999993719 1000000000'