QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#858103 | #9770. Middle Point | chzhc_ | WA | 1ms | 3584kb | C++14 | 1.3kb | 2025-01-16 14:08:32 | 2025-01-16 14:08:50 |
Judging History
answer
#include <bits/stdc++.h>
#define V vector
#define int long long
using namespace std;
signed main() {
int a,b,x,y;
cin>>a>>b>>x>>y;
int ka=1,kb=1,ra=0,rb=0;
while(a%(ka<<1)==0 && a!=0) ka<<=1;
while(b%(kb<<1)==0 && b!=0) kb<<=1;
// cout<<ka<<' '<<kb<<'\n';
ra=a/ka,rb=b/kb;
if(ra>0 && x%ra>0) cout<<-1;
else if(rb>0 && y%rb>0) cout<<-1;
else if((x==a || x==0) && (y==b || y==0)) cout<<0;
else {
int toa=ra>0?x/ra:0,tob=rb>0?y/rb:0;
// cout<<"toa:"<<toa<<' '<<"tob:"<<tob<<'\n';
int ans=0;
if(toa && tob) ans=max(__lg(ka/(toa&-toa)),__lg(kb/(tob&-tob)));
else if(toa) ans=__lg(ka/(toa&-toa));
else if(tob) ans=__lg(kb/(tob&-tob));
V<int> ansax(ans),ansay(ans),ansbx(ans),ansby(ans);
if(toa) for(int i=ans-__lg(ka/(toa&-toa)),j=0;i<ans;i++,j++) if(toa&((toa&-toa)<<j)) ansbx[i]=a;
if(tob) for(int i=ans-__lg(kb/(tob&-tob)),j=0;i<ans;i++,j++) if(tob&((tob&-tob)<<j)) ansby[i]=b;
if(toa==ka) ansax[0]=a;
if(tob==kb) ansay[0]=b;
for(int i=1;i<ans;i++) ansax[i]=(ansax[i-1]+ansbx[i-1])/2;
for(int i=1;i<ans;i++) ansay[i]=(ansay[i-1]+ansby[i-1])/2;
cout<<ans<<'\n';
for(int i=0;i<ans;i++)
cout<<ansax[i]<<' '<<ansay[i]<<' '<<ansbx[i]<<' '<<ansby[i]<<'\n';
}
return 0;
}
详细
Test #1:
score: 100
Accepted
time: 1ms
memory: 3584kb
input:
2 2 1 1
output:
1 0 0 2 2
result:
ok correct!
Test #2:
score: 0
Accepted
time: 0ms
memory: 3584kb
input:
8 8 5 0
output:
3 0 0 8 0 4 0 0 0 2 0 8 0
result:
ok correct!
Test #3:
score: 0
Accepted
time: 0ms
memory: 3584kb
input:
0 0 0 0
output:
0
result:
ok correct!
Test #4:
score: 0
Accepted
time: 0ms
memory: 3584kb
input:
2024 0 1012 0
output:
1 0 0 2024 0
result:
ok correct!
Test #5:
score: 0
Accepted
time: 0ms
memory: 3584kb
input:
2024 2024 2023 2023
output:
-1
result:
ok correct!
Test #6:
score: 0
Accepted
time: 0ms
memory: 3584kb
input:
8 6 7 3
output:
3 0 0 8 0 4 0 8 0 6 0 8 6
result:
ok correct!
Test #7:
score: 0
Accepted
time: 0ms
memory: 3584kb
input:
2024 2026 2024 2026
output:
0
result:
ok correct!
Test #8:
score: 0
Accepted
time: 0ms
memory: 3584kb
input:
1000000000 1000000000 70 0
output:
-1
result:
ok correct!
Test #9:
score: 0
Accepted
time: 0ms
memory: 3584kb
input:
3 6 2 4
output:
-1
result:
ok correct!
Test #10:
score: 0
Accepted
time: 0ms
memory: 3584kb
input:
7 7 7 2
output:
-1
result:
ok correct!
Test #11:
score: 0
Accepted
time: 0ms
memory: 3584kb
input:
6 2 5 2
output:
-1
result:
ok correct!
Test #12:
score: 0
Accepted
time: 0ms
memory: 3584kb
input:
5 7 5 5
output:
-1
result:
ok correct!
Test #13:
score: 0
Accepted
time: 0ms
memory: 3584kb
input:
4 7 2 3
output:
-1
result:
ok correct!
Test #14:
score: -100
Wrong Answer
time: 0ms
memory: 3584kb
input:
8 2 2 2
output:
2 0 2 8 0 4 1 0 0
result:
wrong answer non-lattice point is added into S.