QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#500185#9136. Exponent Calculatorucup-team3734AC ✓11ms10576kbPython31.0kb2024-08-01 00:50:432024-08-01 00:50:43

Judging History

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

  • [2024-08-01 00:50:43]
  • 评测
  • 测评结果:AC
  • 用时:11ms
  • 内存:10576kb
  • [2024-08-01 00:50:43]
  • 提交

answer

ops = list()
ops.append('$1 = $1 * 0.03125')
cs = [
    '1.00000000000409250411',
    '0.99999999996229649302',
    '0.49999999943843465022',
    '0.16666666793726392370',
    '0.04166667869120328771',
    '0.00833332210917809603',
    '0.00138880002043589921',
    '0.00019844700093970611',
    '0.00002506724645050853',
    '0.00000273136629213122',
]

ops.append(f'$0 = {cs[-1]}')
for x in cs[-2::-1]:
    ops.append('$0 = $0 * $1')
    if x == '-':
        ops.append('$0 = $0 - ' + x)
    else:
        ops.append('$0 = $0 + ' + x)

ops.append('$0 = $0 * $0')
ops.append('$0 = $0 * $0')
ops.append('$0 = $0 * $0')
ops.append('$0 = $0 * $0')
ops.append('$0 = $0 * $0')

print(len(ops))
for op in ops:
    print(op)

# import re
# def evl(ops, x):
#     regs = [0.0] * 10
#     regs[1] = x
#     for op in ops:
#         l = re.sub(r'\$(\d+)', r'regs[\1]', op)
#         exec(l)
#         print(op)
#         print(regs)
#     return regs[0]

# import math
# x = -10
# print(evl(ops, x) / math.exp(x))

详细

Test #1:

score: 100
Accepted
time: 11ms
memory: 10576kb

input:

input

output:

25
$1 = $1 * 0.03125
$0 = 0.00000273136629213122
$0 = $0 * $1
$0 = $0 + 0.00002506724645050853
$0 = $0 * $1
$0 = $0 + 0.00019844700093970611
$0 = $0 * $1
$0 = $0 + 0.00138880002043589921
$0 = $0 * $1
$0 = $0 + 0.00833332210917809603
$0 = $0 * $1
$0 = $0 + 0.04166667869120328771
$0 = $0 * $1
$0 = $0 ...

result:

ok max relative diff is 1.55512e-10. Checker runtime is 163 ms

Extra Test:

score: 0
Extra Test Passed