QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#629086 | #2933. Sequinary Numerals | Tenshi# | Compile Error | / | / | C++20 | 677b | 2024-10-11 03:23:45 | 2024-10-11 03:23:46 |
Judging History
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
answer.code:3:3: error: invalid preprocessing directive #signed 3 | # signed main(){ | ^~~~~~ answer.code:4:11: error: invalid preprocessing directive #string 4 | # string s; cin>>s; | ^~~~~~ answer.code:5:11: error: invalid preprocessing directive #reverse 5 | # reverse(all(s)); | ^~~~~~~ answer.code:6:11: error: invalid preprocessing directive #int 6 | # int n=s.size(); | ^~~ answer.code:7:11: error: invalid preprocessing directive #const 7 | # const Node M={{1}, {1, 2}}; | ^~~~~ answer.code:8:11: error: invalid preprocessing directive #Node 8 | # Node B={1, {0, 1}}; | ^~~~ answer.code:9:11: error: invalid preprocessing directive #res 9 | # res={0, {0, 1}}; | ^~~ answer.code:10:11: error: invalid preprocessing directive #rep 10 | # rep(i, 0, n-1){ | ^~~ answer.code:11:19: error: invalid preprocessing directive #Node 11 | # Node val={s[i]-'0', {0, 1}}; | ^~~~ answer.code:12:19: error: invalid preprocessing directive #res 12 | # res=add(res, mul(B, val)); | ^~~ answer.code:14:19: error: invalid preprocessing directive #B 14 | # B=mul(B, M); | ^ answer.code:15:11: error: invalid preprocessing directive #} 15 | # } | ^ answer.code:16:11: error: invalid preprocessing directive #print 16 | # print(res); | ^~~~~ answer.code:17:11: error: invalid preprocessing directive #return 17 | # return 0; | ^~~~~~ answer.code:18:3: error: invalid preprocessing directive #} 18 | # } | ^ answer.code:37:3: error: invalid preprocessing directive #print 37 | # print(x, y) | ^~~~~ answer.code:1:1: error: ‘from’ does not name a type 1 | from fractions import Fraction | ^~~~