QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#189367#2870. Boris and BertaIsaacMoris#AC ✓1ms3608kbC++17991b2023-09-27 13:37:452023-09-27 13:37:45

Judging History

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

  • [2023-09-27 13:37:45]
  • 评测
  • 测评结果:AC
  • 用时:1ms
  • 内存:3608kb
  • [2023-09-27 13:37:45]
  • 提交

answer

#include<iostream>
#include <bits/stdc++.h>

#define ll long long
#define IO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
using namespace std;
const int N = 500 + 5, inf = 2e9;

int calc(int x, int y, int m, int c) {
    return x * m + y * c;
}

void doWork() {
    int n, m, c;
    cin >> n >> m >> c;

    int ans_x = 0, ans_y = 0;


    for (int i = 0; i < c; i++) {
        int cur = i * m;
        int y = 0;
        if (cur <= n) y = (n - cur) / c;

        if (abs(calc(i, y, m, c) - n) < abs(calc(ans_x, ans_y, m, c) - n)) {
            ans_x = i;
            ans_y = y;
        }
        y++;
        if (abs(calc(i, y, m, c) - n) < abs(calc(ans_x, ans_y, m, c) - n)) {
            ans_x = i;
            ans_y = y;
        }
    }
    cout << ans_x << " " << ans_y;
}

int main() {
    IO
    int t = 1;
   // cin >> t;
    for (int i = 1; i <= t; i++) {
        //  cout << "Case #" << i << ": ";
        doWork();
    }
}
 

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

1234
500
169

output:

0 7

result:

ok 

Test #2:

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

input:

1700
500
200

output:

1 6

result:

ok 

Test #3:

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

input:

12345
11299
220

output:

0 56

result:

ok 

Test #4:

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

input:

10000
1000
200

output:

0 50

result:

ok 

Test #5:

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

input:

10000
1000
213

output:

10 0

result:

ok 

Test #6:

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

input:

1
500
169

output:

0 0

result:

ok 

Test #7:

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

input:

1099
900
200

output:

1 1

result:

ok 

Test #8:

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

input:

1100
900
200

output:

1 1

result:

ok 

Test #9:

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

input:

1101
900
200

output:

1 1

result:

ok 

Test #10:

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

input:

1795
900
220

output:

2 0

result:

ok 

Test #11:

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

input:

8584
11299
169

output:

0 51

result:

ok 

Test #12:

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

input:

85
4845
169

output:

0 1

result:

ok 

Test #13:

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

input:

87
7653
170

output:

0 1

result:

ok 

Test #14:

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

input:

170
6477
169

output:

0 1

result:

ok 

Test #15:

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

input:

172
8962
169

output:

0 1

result:

ok 

Test #16:

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

input:

431
500
169

output:

1 0

result:

ok 

Test #17:

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

input:

1344361
11299
220

output:

80 2002

result:

ok 

Test #18:

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

input:

2474261
11299
220

output:

38 9295

result:

ok 

Test #19:

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

input:

3514830
11220
220

output:

0 15976

result:

ok 

Test #20:

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

input:

115004670
11220
220

output:

0 522748

result:

ok 

Test #21:

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

input:

10
7013
212

output:

0 0

result:

ok 

Test #22:

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

input:

766
3734
209

output:

0 4

result:

ok 

Test #23:

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

input:

22162
6263
196

output:

0 113

result:

ok 

Test #24:

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

input:

8174031
7921
172

output:

123 41859

result:

ok 

Test #25:

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

input:

31647263
4029
184

output:

155 168602

result:

ok 

Test #26:

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

input:

361366292
10173
185

output:

64 1949812

result:

ok 

Test #27:

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

input:

977906491
8351
216

output:

101 4523440

result:

ok 

Test #28:

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

input:

999999983
502
172

output:

32 5813860

result:

ok 

Test #29:

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

input:

999999993
11296
218

output:

44 4584876

result:

ok 

Test #30:

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

input:

1000000000
500
169

output:

54 5917000

result:

ok 

Test #31:

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

input:

1000000000
11299
220

output:

60 4542373

result:

ok