CSES - Aalto Competitive Programming 2024 - wk10 - Wed - Results
Submission details
Task:Gas tank
Sender:aalto2024k_004
Submission time:2024-11-13 17:04:02 +0200
Language:C++ (C++17)
Status:READY
Result:
Test results
testverdicttime
#10.00 sdetails
#20.00 sdetails
#30.00 sdetails
#40.00 sdetails
#50.00 sdetails
#60.00 sdetails
#70.00 sdetails
#80.00 sdetails
#90.00 sdetails
#100.00 sdetails
#110.00 sdetails
#120.00 sdetails
#13ACCEPTED0.00 sdetails
#140.00 sdetails
#15ACCEPTED0.00 sdetails
#16ACCEPTED0.00 sdetails
#17ACCEPTED0.00 sdetails
#18ACCEPTED0.00 sdetails
#19ACCEPTED0.00 sdetails
#200.00 sdetails
#21ACCEPTED0.00 sdetails
#220.00 sdetails
#230.00 sdetails
#24ACCEPTED0.00 sdetails
#25ACCEPTED0.00 sdetails
#26ACCEPTED0.00 sdetails
#27ACCEPTED0.00 sdetails
#28ACCEPTED0.00 sdetails
#29ACCEPTED0.00 sdetails
#30ACCEPTED0.00 sdetails
#310.00 sdetails
#320.00 sdetails
#330.00 sdetails
#34ACCEPTED0.00 sdetails
#350.00 sdetails
#360.00 sdetails
#370.00 sdetails
#38ACCEPTED0.00 sdetails
#390.00 sdetails
#400.00 sdetails
#410.00 sdetails
#42ACCEPTED0.00 sdetails
#430.00 sdetails
#440.00 sdetails
#450.00 sdetails
#460.00 sdetails
#47ACCEPTED0.00 sdetails
#480.00 sdetails
#490.00 sdetails
#500.00 sdetails
#510.00 sdetails
#520.00 sdetails
#530.00 sdetails
#540.00 sdetails
#550.00 sdetails
#560.00 sdetails
#570.00 sdetails
#580.00 sdetails
#590.00 sdetails
#600.00 sdetails
#610.00 sdetails
#620.00 sdetails
#630.00 sdetails
#640.00 sdetails
#650.00 sdetails
#660.00 sdetails
#670.00 sdetails
#680.00 sdetails
#690.00 sdetails
#700.00 sdetails
#710.00 sdetails
#720.00 sdetails
#730.00 sdetails
#740.00 sdetails
#750.00 sdetails
#760.00 sdetails
#770.00 sdetails
#780.00 sdetails
#790.00 sdetails
#800.00 sdetails

Code

#include <bits/stdc++.h>

using namespace std;
using ll = long long;

// Debug printing
#ifdef DEBUG
#define deb(fmt, args...) printf("DEBUG: %d: " fmt, __LINE__, ##args)
#define debug_print(fmt, args...) printf(fmt, ##args)
#else
#define deb(fmt, args...)
#define debug_print(fmt, args...)
#endif

void print_array(vector<int> in, const string title = "Vector")
{
	debug_print("DEBUG: %s [\nDEBUG: ", title.c_str());
	for (unsigned int i = 0; i < in.size(); i++) {
		debug_print("%d ", in[i]);
	}
	debug_print("\nDEBUG: ] END\n");
}

void print_matrix(vector<vector<int>> in, const string title = "Matrix")
{
	debug_print("DEBUG: %s [\nDEBUG: ", title.c_str());
	for (unsigned int i = 0; i < in.size(); i++) {
		for (unsigned int j = 0; j < in[i].size(); j++) {
			debug_print("%d ", in[i][j]);
		}
		debug_print("\nDEBUG: ");
	}
	debug_print("DEBUG: ] END\n");
}

int main(int argc, char *argv[])
{
	ios::sync_with_stdio(0);
	cin.tie(0);

	// Read the input parameters
	ll n;
	cin >> n;

	// if ((n & 1) == 1) {
		// n is odd, we cannot ever reach it, make it even
	// 	n--;
	// }

	double err = 0.1;
	while(n > 0) {
		for (ll a = 1; a < 200; a++) {
			double b = 1.0 * a * a;
			ll c = -n;
			double res = (1.0 * -b + sqrt(b * b - 1.0 * 4 * a * c)) / (2 * a);
			double tmp = res;
			double rounded = round(res);
			// deb("a: %d, res: %f, tmp: %f, rounded: %f\n", a, res, tmp, round(res));
			if (abs(tmp - round(res)) <= err) {
				cout << a << " " << (ll)rounded << "\n";
				return 0;
			}
		}
		n--;
	}

	return 0;
}

Test details

Test 1

Verdict:

input
8

correct output
2 1

user output
9 0

Test 2

Verdict:

input
7

correct output
2 1

user output
9 0

Test 3

Verdict:

input
46

correct output
6 1

user output
4 2

Test 4

Verdict:

input
28

correct output
4 1

user output
3 2

Test 5

Verdict:

input
40

correct output
5 1

user output
6 1

Test 6

Verdict:

input
34

correct output
5 1

user output
19 0

Test 7

Verdict:

input
39

correct output
5 1

user output
6 1

Test 8

Verdict:

input
38

correct output
5 1

user output
6 1

Test 9

Verdict:

input
25

correct output
4 1

user output
16 0

Test 10

Verdict:

input
26

correct output
4 1

user output
17 0

Test 11

Verdict:

input
549

correct output
7 6

user output
1 23

Test 12

Verdict:

input
418

correct output
13 2

user output
1 20

Test 13

Verdict: ACCEPTED

input
436

correct output
6 6

user output
6 6

Test 14

Verdict:

input
551

correct output
7 6

user output
1 23

Test 15

Verdict: ACCEPTED

input
968

correct output
21 2

user output
2 21

Test 16

Verdict: ACCEPTED

input
222

correct output
14 1

user output
14 1

Test 17

Verdict: ACCEPTED

input
893

correct output
13 4

user output
4 13

Test 18

Verdict: ACCEPTED

input
77

correct output
8 1

user output
8 1

Test 19

Verdict: ACCEPTED

input
874

correct output
29 1

user output
1 29

Test 20

Verdict:

input
11

correct output
2 1

user output
3 1

Test 21

Verdict: ACCEPTED

input
772

correct output
12 4

user output
4 12

Test 22

Verdict:

input
181

correct output
5 4

user output
1 13

Test 23

Verdict:

input
155

correct output
11 1

user output
1 12

Test 24

Verdict: ACCEPTED

input
778

correct output
12 4

user output
4 12

Test 25

Verdict: ACCEPTED

input
514

correct output
15 2

user output
2 15

Test 26

Verdict: ACCEPTED

input
849

correct output
8 7

user output
7 8

Test 27

Verdict: ACCEPTED

input
224

correct output
14 1

user output
14 1

Test 28

Verdict: ACCEPTED

input
295

correct output
11 2

user output
11 2

Test 29

Verdict: ACCEPTED

input
651

correct output
25 1

user output
1 25

Test 30

Verdict: ACCEPTED

input
98

correct output
6 2

user output
2 6

Test 31

Verdict:

input
588264

correct output
172 18

user output
16 184

Test 32

Verdict:

input
48736

correct output
80 7

user output
3 126

Test 33

Verdict:

input
208508

correct output
99 18

user output
12 126

Test 34

Verdict: ACCEPTED

input
517415

correct output
172 16

user output
16 172

Test 35

Verdict:

input
960234

correct output
290 11

user output
2 692

Test 36

Verdict:

input
870321

correct output
111 49

user output
10 290

Test 37

Verdict:

input
308005

correct output
70 40

user output
3 319

Test 38

Verdict: ACCEPTED

input
425818

correct output
652 1

user output
1 652

Test 39

Verdict:

input
729178

correct output
83 61

user output
4 425

Test 40

Verdict:

input
863955

correct output
535 3

user output
1 929

Test 41

Verdict:

input
116086

correct output
340 1

user output
2 240

Test 42

Verdict: ACCEPTED

input
612309

correct output
782 1

user output
1 782

Test 43

Verdict:

input
375142

correct output
228 7

user output
1 612

Test 44

Verdict:

input
852178

correct output
161 28

user output
10 287

Test 45

Verdict:

input
151667

correct output
156 6

user output
1 389

Test 46

Verdict:

input
196137

correct output
103 16

user output
7 164

Test 47

Verdict: ACCEPTED

input
375254

correct output
612 1

user output
1 612

Test 48

Verdict:

input
451513

correct output
298 5

user output
4 334

Test 49

Verdict:

input
942864

correct output
122 46

user output
18 220

Test 50

Verdict:

input
848035

correct output
215 17

user output
6 373

Test 51

Verdict:

input
727949226

correct output
1876 188

user output
1 26980

Test 52

Verdict:

input
119540561

correct output
395 387

user output
1 10933

Test 53

Verdict:

input
168568700

correct output
447 430

user output
1 12983

Test 54

Verdict:

input
747828096

correct output
2098 158

user output
1 27346

Test 55

Verdict:

input
113886324

correct output
949 113

user output
2 7545

Test 56

Verdict:

input
544092912

correct output
2620 77

user output
8 8243

Test 57

Verdict:

input
112927706

correct output
532 266

user output
5 4750

Test 58

Verdict:

input
562461747

correct output
1803 159

user output
2 16769

Test 59

Verdict:

input
930544437

correct output
7390 17

user output
8 10781

Test 60

Verdict:

input
612603672

correct output
1128 364

user output
10 7822

Test 61

Verdict:

input
575864416073

correct output
7427 5843

user output
3 438125

Test 62

Verdict:

input
942935707814

correct output
63092 236

user output
6 396426

Test 63

Verdict:

input
171264013251

correct output
14433 780

user output
1 413840

Test 64

Verdict:

input
76712165827

correct output
8381 978

user output
2 195846

Test 65

Verdict:

input
161612205399

correct output
7527 2206

user output
5 179782

Test 66

Verdict:

input
641183113758

correct output
50116 254

user output
2 566207

Test 67

Verdict:

input
87822361843

correct output
24538 145

user output
2 209549

Test 68

Verdict:

input
550401843854

correct output
14093 2372

user output
2 524595

Test 69

Verdict:

input
56603972680

correct output
10404 499

user output
2 168231

Test 70

Verdict:

input
991404337870

correct output
109250 83

user output
3 574862

Test 71

Verdict:

input
534149659344

correct output
53496 186

user output
1 730855

Test 72

Verdict:

input
336010906011

correct output
183301 10

user output
1 579664

Test 73

Verdict:

input
871714540470

correct output
214186 19

user output
1 933656

Test 74

Verdict:

input
254659717917

correct output
17240 818

user output
2 356832

Test 75

Verdict:

input
40507166127

correct output
3335 2196

user output
2 142314

Test 76

Verdict:

input
445628406612

correct output
23039 811

user output
2 472031

Test 77

Verdict:

input
822717753419

correct output
39363 524

user output
3 523677

Test 78

Verdict:

input
40410210216

correct output
10096 382

user output
7 75976

Test 79

Verdict:

input
366117794932

correct output
49165 151

user output
5 270596

Test 80

Verdict:

input
657992849714

correct output
11698 3662

user output
1 811167