QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#22631 | #2870. Boris and Berta | WhybullYMe# | AC ✓ | 4ms | 3848kb | C++20 | 829b | 2022-03-10 14:21:16 | 2022-04-30 01:28:25 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
#define ri int
typedef long long ll;
const int maxn=1e5+10;
template<class T>inline bool ckmin(T &x,const T &y){return x>y?x=y,1:0;}
template<class T>inline bool ckmax(T &x,const T &y){return x<y?x=y,1:0;}
template<class T>inline void clear(T *arr,int siz,int val=0){memset(arr,val,sizeof(T)*(siz+1));}
int ans=INT_MAX,c,m,n,x,y;
int main(){
scanf("%d%d%d",&n,&m,&c);
ri l1=n/m;
for(ri i=max(l1-500,0);i<=l1+500;++i){
ri l2=(n-i*m)/c;
for(ri j=max(l2-500,0);j<=l2+500;++j)
if(abs(i*m+j*c-n)<ans)
ans=abs(i*m+j*c-n),x=i,y=j;
}
swap(m,c);
l1=n/m;
for(ri i=max(l1-500,0);i<=l1+500;++i){
ri l2=(n-i*m)/c;
for(ri j=max(l2-500,0);j<=l2+500;++j)
if(abs(i*m+j*c-n)<ans)
ans=abs(i*m+j*c-n),x=j,y=i;
}
printf("%d %d",x,y);
return 0;
}
詳細信息
Test #1:
score: 100
Accepted
time: 3ms
memory: 3788kb
input:
1234 500 169
output:
0 7
result:
ok
Test #2:
score: 0
Accepted
time: 3ms
memory: 3780kb
input:
1700 500 200
output:
1 6
result:
ok
Test #3:
score: 0
Accepted
time: 3ms
memory: 3728kb
input:
12345 11299 220
output:
0 56
result:
ok
Test #4:
score: 0
Accepted
time: 3ms
memory: 3792kb
input:
10000 1000 200
output:
0 50
result:
ok
Test #5:
score: 0
Accepted
time: 1ms
memory: 3784kb
input:
10000 1000 213
output:
10 0
result:
ok
Test #6:
score: 0
Accepted
time: 3ms
memory: 3688kb
input:
1 500 169
output:
0 0
result:
ok
Test #7:
score: 0
Accepted
time: 1ms
memory: 3780kb
input:
1099 900 200
output:
1 1
result:
ok
Test #8:
score: 0
Accepted
time: 0ms
memory: 3644kb
input:
1100 900 200
output:
1 1
result:
ok
Test #9:
score: 0
Accepted
time: 3ms
memory: 3788kb
input:
1101 900 200
output:
1 1
result:
ok
Test #10:
score: 0
Accepted
time: 1ms
memory: 3808kb
input:
1795 900 220
output:
2 0
result:
ok
Test #11:
score: 0
Accepted
time: 3ms
memory: 3844kb
input:
8584 11299 169
output:
0 51
result:
ok
Test #12:
score: 0
Accepted
time: 0ms
memory: 3844kb
input:
85 4845 169
output:
0 1
result:
ok
Test #13:
score: 0
Accepted
time: 1ms
memory: 3780kb
input:
87 7653 170
output:
0 1
result:
ok
Test #14:
score: 0
Accepted
time: 0ms
memory: 3788kb
input:
170 6477 169
output:
0 1
result:
ok
Test #15:
score: 0
Accepted
time: 0ms
memory: 3788kb
input:
172 8962 169
output:
0 1
result:
ok
Test #16:
score: 0
Accepted
time: 3ms
memory: 3760kb
input:
431 500 169
output:
1 0
result:
ok
Test #17:
score: 0
Accepted
time: 3ms
memory: 3764kb
input:
1344361 11299 220
output:
80 2002
result:
ok
Test #18:
score: 0
Accepted
time: 3ms
memory: 3812kb
input:
2474261 11299 220
output:
38 9295
result:
ok
Test #19:
score: 0
Accepted
time: 3ms
memory: 3780kb
input:
3514830 11220 220
output:
0 15976
result:
ok
Test #20:
score: 0
Accepted
time: 0ms
memory: 3732kb
input:
115004670 11220 220
output:
9749 25549
result:
ok
Test #21:
score: 0
Accepted
time: 3ms
memory: 3808kb
input:
10 7013 212
output:
0 0
result:
ok
Test #22:
score: 0
Accepted
time: 4ms
memory: 3784kb
input:
766 3734 209
output:
0 4
result:
ok
Test #23:
score: 0
Accepted
time: 3ms
memory: 3784kb
input:
22162 6263 196
output:
0 113
result:
ok
Test #24:
score: 0
Accepted
time: 3ms
memory: 3684kb
input:
8174031 7921 172
output:
639 18096
result:
ok
Test #25:
score: 0
Accepted
time: 3ms
memory: 3780kb
input:
31647263 4029 184
output:
7515 7442
result:
ok
Test #26:
score: 0
Accepted
time: 3ms
memory: 3712kb
input:
361366292 10173 185
output:
35029 27115
result:
ok
Test #27:
score: 0
Accepted
time: 3ms
memory: 3776kb
input:
977906491 8351 216
output:
116741 13900
result:
ok
Test #28:
score: 0
Accepted
time: 3ms
memory: 3848kb
input:
999999983 502 172
output:
1991534 1453
result:
ok
Test #29:
score: 0
Accepted
time: 1ms
memory: 3708kb
input:
999999993 11296 218
output:
88056 24401
result:
ok
Test #30:
score: 0
Accepted
time: 0ms
memory: 3848kb
input:
1000000000 500 169
output:
1999662 1000
result:
ok
Test #31:
score: 0
Accepted
time: 1ms
memory: 3760kb
input:
1000000000 11299 220
output:
88060 22773
result:
ok