QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#629087#2933. Sequinary NumeralsTenshi#AC ✓23ms11804kbPython3677b2024-10-11 03:23:592024-10-11 03:23:59

Judging History

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

  • [2024-10-11 03:23:59]
  • 评测
  • 测评结果:AC
  • 用时:23ms
  • 内存:11804kb
  • [2024-10-11 03:23:59]
  • 提交

answer

from fractions import Fraction

# signed main(){
	# string s; cin>>s;
	# reverse(all(s));
	# int n=s.size();
	# const Node M={{1}, {1, 2}};
	# Node B={1, {0, 1}};
	# res={0, {0, 1}};
	# rep(i, 0, n-1){
		# Node val={s[i]-'0', {0, 1}};
		# res=add(res, mul(B, val));
# 		
		# B=mul(B, M);
	# }
	# print(res);
	# return 0;
# }

s = input()
s = s[::-1]
n = len(s)

M = Fraction(3, 2)
B = Fraction(1, 1)

res = Fraction(0, 1)

for i in range(n):
	val = Fraction(int(s[i]), 1)
	res += B * val
	B *= M

x = res.numerator
y = res.denominator

# print(x, y)

if y == 1:
	print(x)
else:
	print(x // y, end=' ')
	print(str(x % y) + "/" + str(y))

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 10ms
memory: 11760kb

input:

2101

output:

10

result:

ok single line: '10'

Test #2:

score: 0
Accepted
time: 23ms
memory: 11804kb

input:

201

output:

5 1/2

result:

ok single line: '5 1/2'

Test #3:

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

input:

2010211122112221202012

output:

16541 873801/1048576

result:

ok single line: '16541 873801/1048576'

Test #4:

score: 0
Accepted
time: 19ms
memory: 11696kb

input:

22222222222222222222222222222222

output:

1725755 572407425/1073741824

result:

ok single line: '1725755 572407425/1073741824'

Test #5:

score: 0
Accepted
time: 16ms
memory: 11804kb

input:

11111111111111111111111111111111

output:

862877 1646149249/2147483648

result:

ok single line: '862877 1646149249/2147483648'

Test #6:

score: 0
Accepted
time: 18ms
memory: 11656kb

input:

10000000000000000000000000000000

output:

287626 1264544299/2147483648

result:

ok single line: '287626 1264544299/2147483648'

Test #7:

score: 0
Accepted
time: 13ms
memory: 11588kb

input:

1

output:

1

result:

ok single line: '1'

Test #8:

score: 0
Accepted
time: 21ms
memory: 11740kb

input:

2

output:

2

result:

ok single line: '2'

Test #9:

score: 0
Accepted
time: 22ms
memory: 11696kb

input:

10

output:

1 1/2

result:

ok single line: '1 1/2'

Test #10:

score: 0
Accepted
time: 21ms
memory: 11744kb

input:

11

output:

2 1/2

result:

ok single line: '2 1/2'

Test #11:

score: 0
Accepted
time: 18ms
memory: 11692kb

input:

12

output:

3 1/2

result:

ok single line: '3 1/2'

Test #12:

score: 0
Accepted
time: 22ms
memory: 11740kb

input:

20

output:

3

result:

ok single line: '3'

Test #13:

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

input:

21

output:

4

result:

ok single line: '4'

Test #14:

score: 0
Accepted
time: 17ms
memory: 11688kb

input:

22

output:

5

result:

ok single line: '5'

Test #15:

score: 0
Accepted
time: 16ms
memory: 11656kb

input:

201000101020120002210001022

output:

99539 7418955/33554432

result:

ok single line: '99539 7418955/33554432'

Test #16:

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

input:

21012020111221210112111012122211

output:

1056241 54451731/134217728

result:

ok single line: '1056241 54451731/134217728'

Test #17:

score: 0
Accepted
time: 14ms
memory: 11696kb

input:

121200

output:

25 19/32

result:

ok single line: '25 19/32'

Test #18:

score: 0
Accepted
time: 15ms
memory: 11740kb

input:

22010

output:

18 3/8

result:

ok single line: '18 3/8'

Test #19:

score: 0
Accepted
time: 17ms
memory: 11800kb

input:

1102121021020020112221202220100

output:

565301 930420511/1073741824

result:

ok single line: '565301 930420511/1073741824'

Test #20:

score: 0
Accepted
time: 19ms
memory: 11764kb

input:

1022020000221011110121211

output:

47476 16343961/16777216

result:

ok single line: '47476 16343961/16777216'

Test #21:

score: 0
Accepted
time: 14ms
memory: 11692kb

input:

21100210121101

output:

698 349/2048

result:

ok single line: '698 349/2048'

Test #22:

score: 0
Accepted
time: 15ms
memory: 11760kb

input:

122110002

output:

97 61/256

result:

ok single line: '97 61/256'

Test #23:

score: 0
Accepted
time: 23ms
memory: 11688kb

input:

200200011120110

output:

806 6545/8192

result:

ok single line: '806 6545/8192'

Test #24:

score: 0
Accepted
time: 22ms
memory: 11688kb

input:

212020012222220200010110012112

output:

540506 7899177/8388608

result:

ok single line: '540506 7899177/8388608'

Test #25:

score: 0
Accepted
time: 21ms
memory: 11676kb

input:

21201001011

output:

222 19/64

result:

ok single line: '222 19/64'