QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#201370 | #5154. ETA | S_Explosion# | WA | 1ms | 3820kb | C++20 | 1.2kb | 2023-10-05 13:59:33 | 2023-10-05 13:59:34 |
Judging History
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+(i*b-j)&&tot<=j*(j+1)/2+(i*b-j-1)){
for(int k=1;k<j;k++){
printf("%lld %lld\n",k,k+1);
}
int rem=tot-(j*(j-1)/2)-(i*b-j);
// assert(rem>=0);
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: 3752kb
input:
1/2
output:
2 1 2 1
result:
ok
Test #2:
score: 0
Accepted
time: 1ms
memory: 3760kb
input:
1/3
output:
impossible
result:
ok
Test #3:
score: 0
Accepted
time: 0ms
memory: 3764kb
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: 3820kb
input:
974/975
output:
975 974 2 1 3 1 4 1 5 1 6 1 7 1 8 1 9 1 10 1 11 1 12 1 13 1 14 1 15 1 16 1 17 1 18 1 19 1 20 1 21 1 22 1 23 1 24 1 25 1 26 1 27 1 28 1 29 1 30 1 31 1 32 1 33 1 34 1 35 1 36 1 37 1 38 1 39 1 40 1 41 1 42 1 43 1 44 1 45 1 46 1 47 1 48 1 49 1 50 1 51 1 52 1 53 1 54 1 55 1 56 1 57 1 58 1 59 1 60 1 61 1 ...
result:
wrong output format Extra information in the output file