QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#365223#2870. Boris and BertahazeAC ✓32ms3724kbC++231.6kb2024-03-24 22:04:582024-03-24 22:04:59

Judging History

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

  • [2024-03-24 22:04:59]
  • 评测
  • 测评结果:AC
  • 用时:32ms
  • 内存:3724kb
  • [2024-03-24 22:04:58]
  • 提交

answer

/*

Author: Haze

2024/3/24

*/

#include <bits/stdc++.h>

#define irep(i, l, r) for(int i = (l); i <= (r); ++ i)
#define drep(i, r, l) for(int i = (r); i >= (l); -- i)
#define IOS ios::sync_with_stdio(false), cin.tie(nullptr);
using namespace std;
typedef long long ll;

inline ll read() {
    ll s = 0;
    bool fl = false;
    char ch = (char) getchar();
    while (!isdigit(ch)) {
        if (ch == '-')fl = true;
        ch = (char) getchar();
    }
    while (isdigit(ch)) {
        s = s * 10 + (ch ^ 48);
        ch = (char) getchar();
    }
    return fl ? -s : s;
}

const int mod = 1000000000 + 7;
const int itinf = 1000000999;
const ll llinf = 2e18;
const int N = 500099;

ll Abs(ll x){
    return x > 0 ? x : -x;
}

void solve() {
    ll n = read(), a = read(), b = read(), c = a * b;
    ll j = 1e7;
    ll res = llinf, x, y;
    for(ll i = 0; i <= n / a + 100; ++ i){
        while(j > 0 && n - (i * a + j * b) <= 0){
            -- j;
        }
        for(int j0 = max(j - 10, 0ll); j0 <= j + 10; ++ j0){
            if(Abs(i * a + j0 * b - n) <= res){
                x = i, y = j0;
                res = Abs(i * a + j0 * b - n);
            }
        }

    }
//    ll p = (n / c) * b;
//
//    ll res = llinf, x, y;
//    for(ll i = p; i <= p + 1000; ++ i){
//        for(ll j = 0; j <= 22000; ++ j){
//
//        }
//    }
    cout << x << ' ' << y;
////    cerr << res;
}

int main() {
    // IOS
    int T = 1;
    while (T--) {
        solve();
    }
    return 0;
}
/*
2214408
11299
197
 */

详细

Test #1:

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

input:

1234
500
169

output:

0 7

result:

ok 

Test #2:

score: 0
Accepted
time: 3ms
memory: 3648kb

input:

1700
500
200

output:

3 1

result:

ok 

Test #3:

score: 0
Accepted
time: 3ms
memory: 3664kb

input:

12345
11299
220

output:

0 56

result:

ok 

Test #4:

score: 0
Accepted
time: 3ms
memory: 3704kb

input:

10000
1000
200

output:

10 0

result:

ok 

Test #5:

score: 0
Accepted
time: 4ms
memory: 3648kb

input:

10000
1000
213

output:

10 0

result:

ok 

Test #6:

score: 0
Accepted
time: 3ms
memory: 3648kb

input:

1
500
169

output:

0 0

result:

ok 

Test #7:

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

input:

1099
900
200

output:

1 1

result:

ok 

Test #8:

score: 0
Accepted
time: 4ms
memory: 3724kb

input:

1100
900
200

output:

1 1

result:

ok 

Test #9:

score: 0
Accepted
time: 3ms
memory: 3660kb

input:

1101
900
200

output:

1 1

result:

ok 

Test #10:

score: 0
Accepted
time: 4ms
memory: 3708kb

input:

1795
900
220

output:

2 0

result:

ok 

Test #11:

score: 0
Accepted
time: 3ms
memory: 3660kb

input:

8584
11299
169

output:

0 51

result:

ok 

Test #12:

score: 0
Accepted
time: 3ms
memory: 3580kb

input:

85
4845
169

output:

0 1

result:

ok 

Test #13:

score: 0
Accepted
time: 3ms
memory: 3648kb

input:

87
7653
170

output:

0 1

result:

ok 

Test #14:

score: 0
Accepted
time: 3ms
memory: 3648kb

input:

170
6477
169

output:

0 1

result:

ok 

Test #15:

score: 0
Accepted
time: 3ms
memory: 3660kb

input:

172
8962
169

output:

0 1

result:

ok 

Test #16:

score: 0
Accepted
time: 3ms
memory: 3660kb

input:

431
500
169

output:

1 0

result:

ok 

Test #17:

score: 0
Accepted
time: 3ms
memory: 3652kb

input:

1344361
11299
220

output:

80 2002

result:

ok 

Test #18:

score: 0
Accepted
time: 3ms
memory: 3712kb

input:

2474261
11299
220

output:

180 2002

result:

ok 

Test #19:

score: 0
Accepted
time: 3ms
memory: 3632kb

input:

3514830
11220
220

output:

313 14

result:

ok 

Test #20:

score: 0
Accepted
time: 4ms
memory: 3704kb

input:

115004670
11220
220

output:

10249 50

result:

ok 

Test #21:

score: 0
Accepted
time: 3ms
memory: 3644kb

input:

10
7013
212

output:

0 0

result:

ok 

Test #22:

score: 0
Accepted
time: 3ms
memory: 3652kb

input:

766
3734
209

output:

0 4

result:

ok 

Test #23:

score: 0
Accepted
time: 3ms
memory: 3700kb

input:

22162
6263
196

output:

0 113

result:

ok 

Test #24:

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

input:

8174031
7921
172

output:

983 2254

result:

ok 

Test #25:

score: 0
Accepted
time: 4ms
memory: 3648kb

input:

31647263
4029
184

output:

7699 3413

result:

ok 

Test #26:

score: 0
Accepted
time: 4ms
memory: 3588kb

input:

361366292
10173
185

output:

35399 6769

result:

ok 

Test #27:

score: 0
Accepted
time: 5ms
memory: 3660kb

input:

977906491
8351
216

output:

116957 5549

result:

ok 

Test #28:

score: 0
Accepted
time: 32ms
memory: 3648kb

input:

999999983
502
172

output:

1992001 90

result:

ok 

Test #29:

score: 0
Accepted
time: 5ms
memory: 3584kb

input:

999999993
11296
218

output:

88492 1809

result:

ok 

Test #30:

score: 0
Accepted
time: 31ms
memory: 3708kb

input:

1000000000
500
169

output:

2000000 0

result:

ok 

Test #31:

score: 0
Accepted
time: 5ms
memory: 3648kb

input:

1000000000
11299
220

output:

88500 175

result:

ok