QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#201339#5154. ETAS_Explosion#WA 1ms3884kbC++201.2kb2023-10-05 13:48:542023-10-05 13:48:54

Judging History

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

  • [2023-10-05 13:48:54]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3884kb
  • [2023-10-05 13:48:54]
  • 提交

answer

#include <bits/stdc++.h>
#define int long long
using namespace std;
int a,b;
inline int read(){
    int ret=0,ff=1;char ch=getchar();
    while(!isdigit(ch)){if(ch=='-')ff=-1;ch=getchar();}
    while(isdigit(ch)){ret=ret*10+(ch^48);ch=getchar();}
    return ret*ff;
}
signed main(){
    a=read(),b=read();
    int g=__gcd(a,b);
    a/=g,b/=g;
    for(int i=1;i*b<=1000000;i++){
        int tot=i*a;
        if(tot>=i*b-1&&tot<=i*b*(i*b-1)/2){
            printf("%lld %lld\n",i*b,i*b-1);
            for(int j=1;j<i*b;j++){
                if(tot>=j*(j-1)/2&&tot<=j*(j+1)/2){
                    for(int k=1;k<j;k++){
                        printf("%lld %lld\n",k,k+1);
                    }
                    int rem=tot-(j*(j-1)/2)-(i*b-j);
                    for(int k=1;k<=i*b-j;k++){
                        if(rem){
                            printf("%lld %lld\n",j+k,min(j-1,rem)+1);
                            rem-=min(j-1,rem);
                        }
                        else printf("%lld %lld\n",j+k,1ll);
                    }
                }
            }
            return 0;
        }
    }
    printf("impossible");
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

1/2

output:

2 1
2 1

result:

ok 

Test #2:

score: 0
Accepted
time: 1ms
memory: 3792kb

input:

1/3

output:

impossible

result:

ok 

Test #3:

score: 0
Accepted
time: 0ms
memory: 3828kb

input:

7/4

output:

8 7
1 2
2 3
3 4
4 5
6 2
7 1
8 1

result:

ok 

Test #4:

score: -100
Wrong Answer
time: 0ms
memory: 3884kb

input:

974/975

output:

975 974
1 2
2 3
3 4
4 5
5 6
6 7
7 8
8 9
9 10
10 11
11 12
12 13
13 14
14 15
15 16
16 17
17 18
18 19
19 20
20 21
21 22
22 23
23 24
24 25
25 26
26 27
27 28
28 29
29 30
30 31
31 32
32 33
33 34
34 35
35 36
36 37
37 38
38 39
39 40
40 41
41 42
42 43
43 44
45 -902
46 1
47 1
48 1
49 1
50 1
51 1
52 1
53 1
54 ...

result:

wrong answer Integer parameter [name=y] equals to -902, violates the range [1, 975]