QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#31252#2105. DominoQingyu✨100 ✓9ms3936kbC++23738b2022-05-05 20:40:022022-05-05 20:40:03

Judging History

This is the latest submission verdict.

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2022-05-05 20:40:03]
  • Judged
  • Verdict: 100
  • Time: 9ms
  • Memory: 3936kb
  • [2022-05-05 20:40:02]
  • Submitted

answer

#include <bits/stdc++.h>

int main() {
	int64_t m;
	std::cin >> m;
	if (m == 1) {
		std::cout << 1 << '\n';
		return 0;
	}
	std::map<int64_t, int> f;
	std::vector<int64_t> fib = {1, 1};
	while (fib.back() < m) {
		int t = fib.size();
		fib.push_back(fib[t - 1] + fib[t - 2]);
	}
	auto dfs = [&](auto &self, int64_t prod) -> int {
		if (f.count(prod))
			return f[prod];
		if (prod == 1)
			return 0;
		int ans = 0x3f3f3f3f;
		for (int i = 2; i < fib.size(); ++i) {
			if (prod % fib[i] == 0) {
				ans = std::min(ans, self(self, prod / fib[i]) + i + 1);
			}	
		}
		return f[prod] = ans;
	};
	int ans = dfs(dfs, m);
	if (ans == 0x3f3f3f3f) std::cout << "NIE" << '\n';
	else std::cout << ans - 1 << '\n';
}

Details

Tip: Click on the bar to expand more detailed information

Subtask #1:

score: 20
Accepted

Test #1:

score: 20
Accepted
time: 2ms
memory: 3512kb

input:

4

output:

5

result:

ok single line: '5'

Test #2:

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

input:

101

output:

NIE

result:

ok single line: 'NIE'

Test #3:

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

input:

1

output:

1

result:

ok single line: '1'

Test #4:

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

input:

9

output:

7

result:

ok single line: '7'

Test #5:

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

input:

2

output:

2

result:

ok single line: '2'

Test #6:

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

input:

11

output:

NIE

result:

ok single line: 'NIE'

Test #7:

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

input:

5

output:

4

result:

ok single line: '4'

Subtask #2:

score: 30
Accepted

Test #8:

score: 30
Accepted
time: 0ms
memory: 3696kb

input:

500

output:

20

result:

ok single line: '20'

Test #9:

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

input:

6

output:

6

result:

ok single line: '6'

Test #10:

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

input:

112233445566778899

output:

NIE

result:

ok single line: 'NIE'

Test #11:

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

input:

9

output:

7

result:

ok single line: '7'

Test #12:

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

input:

15

output:

8

result:

ok single line: '8'

Test #13:

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

input:

34

output:

8

result:

ok single line: '8'

Test #14:

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

input:

12

output:

9

result:

ok single line: '9'

Test #15:

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

input:

25

output:

9

result:

ok single line: '9'

Test #16:

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

input:

65

output:

11

result:

ok single line: '11'

Test #17:

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

input:

30

output:

11

result:

ok single line: '11'

Test #18:

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

input:

64

output:

11

result:

ok single line: '11'

Test #19:

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

input:

144

output:

11

result:

ok single line: '11'

Test #20:

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

input:

45

output:

12

result:

ok single line: '12'

Test #21:

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

input:

48

output:

12

result:

ok single line: '12'

Test #22:

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

input:

104

output:

12

result:

ok single line: '12'

Test #23:

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

input:

105

output:

12

result:

ok single line: '12'

Test #24:

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

input:

233

output:

12

result:

ok single line: '12'

Test #25:

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

input:

55440

output:

30

result:

ok single line: '30'

Test #26:

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

input:

1609776

output:

37

result:

ok single line: '37'

Test #27:

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

input:

352512

output:

34

result:

ok single line: '34'

Test #28:

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

input:

856800

output:

39

result:

ok single line: '39'

Test #29:

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

input:

994896

output:

36

result:

ok single line: '36'

Test #30:

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

input:

1016064

output:

36

result:

ok single line: '36'

Test #31:

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

input:

1032192

output:

41

result:

ok single line: '41'

Test #32:

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

input:

1174320

output:

38

result:

ok single line: '38'

Test #33:

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

input:

1799280

output:

39

result:

ok single line: '39'

Test #34:

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

input:

1525104

output:

37

result:

ok single line: '37'

Test #35:

score: 0
Accepted
time: 2ms
memory: 3620kb

input:

49686

output:

NIE

result:

ok single line: 'NIE'

Test #36:

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

input:

269581

output:

30

result:

ok single line: '30'

Test #37:

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

input:

487296

output:

NIE

result:

ok single line: 'NIE'

Test #38:

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

input:

514229

output:

28

result:

ok single line: '28'

Test #39:

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

input:

1376375

output:

NIE

result:

ok single line: 'NIE'

Test #40:

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

input:

1346269

output:

30

result:

ok single line: '30'

Test #41:

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

input:

1875750

output:

NIE

result:

ok single line: 'NIE'

Test #42:

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

input:

974170

output:

31

result:

ok single line: '31'

Test #43:

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

input:

1539648

output:

NIE

result:

ok single line: 'NIE'

Test #44:

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

input:

1990656

output:

39

result:

ok single line: '39'

Subtask #3:

score: 50
Accepted

Dependency #1:

100%
Accepted

Dependency #2:

100%
Accepted

Test #45:

score: 50
Accepted
time: 2ms
memory: 3608kb

input:

911980368

output:

52

result:

ok single line: '52'

Test #46:

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

input:

508149401760

output:

70

result:

ok single line: '70'

Test #47:

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

input:

22293710184240

output:

73

result:

ok single line: '73'

Test #48:

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

input:

7739040938471136

output:

85

result:

ok single line: '85'

Test #49:

score: 0
Accepted
time: 6ms
memory: 3924kb

input:

732129230650245120

output:

98

result:

ok single line: '98'

Test #50:

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

input:

502441643974298112

output:

92

result:

ok single line: '92'

Test #51:

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

input:

812967657313788144

output:

93

result:

ok single line: '93'

Test #52:

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

input:

152786297281314816

output:

98

result:

ok single line: '98'

Test #53:

score: 0
Accepted
time: 6ms
memory: 3800kb

input:

86225915457110016

output:

100

result:

ok single line: '100'

Test #54:

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

input:

567453553048682496

output:

119

result:

ok single line: '119'

Test #55:

score: 0
Accepted
time: 9ms
memory: 3936kb

input:

462839585817248640

output:

97

result:

ok single line: '97'

Test #56:

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

input:

473283814927590576

output:

97

result:

ok single line: '97'

Test #57:

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

input:

288103580967051360

output:

96

result:

ok single line: '96'

Test #58:

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

input:

429136396059420000

output:

95

result:

ok single line: '95'

Test #59:

score: 0
Accepted
time: 8ms
memory: 3840kb

input:

807314262090336000

output:

98

result:

ok single line: '98'

Test #60:

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

input:

20035952640

output:

NIE

result:

ok single line: 'NIE'

Test #61:

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

input:

576460752303423488

output:

119

result:

ok single line: '119'

Test #62:

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

input:

552793856617800

output:

NIE

result:

ok single line: 'NIE'

Test #63:

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

input:

991948530947554970

output:

90

result:

ok single line: '90'

Test #64:

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

input:

754140816224510546

output:

NIE

result:

ok single line: 'NIE'

Test #65:

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

input:

679891637638612258

output:

86

result:

ok single line: '86'

Test #66:

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

input:

694363971663288479

output:

NIE

result:

ok single line: 'NIE'

Test #67:

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

input:

1517398753590850

output:

80

result:

ok single line: '80'

Test #68:

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

input:

999999999999999967

output:

NIE

result:

ok single line: 'NIE'

Test #69:

score: 0
Accepted
time: 2ms
memory: 3492kb

input:

692290561159

output:

59

result:

ok single line: '59'

Extra Test:

score: 0
Extra Test Passed