QOJ.ac

QOJ

時間限制: 1 s 記憶體限制: 1024 MB 總分: 100

#14855. 意外的算术

统计

你信赖的“易碎算术便携式计算器”。插图由 Freek Henstra 绘制

今天是 2025 年 1 月 25 日。你正在撰写统计学课程的期末报告。然而,当你将计算数据输入到你信赖的“易碎算术便携式计算器”(Brittle Arithmetic Portable Calculator)中时,你发现 $+$ 和 $-$ 键失灵了。每当你按下数字键($0$ 到 $9$ 中的一个键)时,紧接着可能会多注册一次按键:要么是 $+$ 键,要么是 $-$ 键,要么什么都没有(但绝不会两者同时出现)。“唉,”你心想,“我为什么没有买一个‘备用算术便携式计算器’呢……”但随后你产生了一个想法,可以让自己免于拿到低分。

经过一番实验,你通过统计确定,按下数字键有 $45\%$ 的概率会多输入一个 $+$,同样也有 $45\%$ 的概率会多输入一个 $-$(且绝不会同时出现两者)。你决定围绕你的发现来撰写报告。除了统计分析之外,老师还要求你基于统计模型进行一些概率预测。你决定研究当你尝试简单地输入一个自然数时,你的计算器会做出什么反应。

给定一个自然数 $n$,你考虑通过按下对应于 $n$ 的标准十进制表示的数字键,将该数字输入到计算器中。计算器可能会在 $n$ 的数字之间注册 $+$ 或 $-$ 的按键,从而产生一个算术表达式。你想知道如果按下 $=$ 来计算该表达式会发生什么。幸运的是,如果你的表达式以 $+$ 或 $-$ 结尾,计算器会忽略它,因此这种计算总是会得到一个整数。为了完成报告,你决定编写一个程序,对于给定的任意 $n$,计算该结果的期望值。

输入格式

输入包含:

  • 一行,包含一个整数 $n$($0 \le n < 10^{1000}$),即你将输入到计算器中的数字。

输出格式

输出结果的期望值。

你的答案与真实值之间的绝对误差或相对误差应不超过 $10^{-6}$。

样例

输入样例 1

12345

输出样例 1

5.4321

输入样例 2

777777

输出样例 2

42

输入样例 3

31415926535897932384626433832795028841971693993751

输出样例 3

141.5189

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.