Files
freeCodeCamp/curriculum/challenges/japanese/10-coding-interview-prep/project-euler/problem-423-consecutive-die-throws.md
2022-04-02 17:46:30 +09:00

1.6 KiB

id, title, challengeType, forumTopicId, dashedName
id title challengeType forumTopicId dashedName
5900f5141000cf542c510027 問題 423: 連続サイコロ投げ 5 302093 problem-423-consecutive-die-throws

--description--

n を正の整数とします。

6 面サイコロを n 回投げます。 連続する同じ出目の対がいくつあるかを c で表します。

例えば、$n = 7$、サイコロの出目が (1, 1, 5, 6, 6, 6, 3) の場合、連続する同じ出目の対は次のとおりです。

$$\begin{align} & (\underline{1}, \underline{1}, 5, 6, 6, 6, 3) \\ & (1, 1, 5, \underline{6}, \underline{6}, 6, 3) \\ & (1, 1, 5, 6, \underline{6}, \underline{6}, 3) \end{align}$$

したがって、(1, 1, 5, 6, 6, 6, 3) のとき、c = 3 になります。

6 面サイコロを n 回投げた結果のうち、cπ(n) を超えない結果の数を C(n) とします1

例えば、C(3) = 216, C(4) = 1290, C(11) = 361\\,912\\,500, C(24) = 4\\,727\\,547\\,363\\,281\\,250\\,000 です。

1 ≤ n ≤ L のとき、\sum C(n)S(L) と定義します。

例えば、S(50)\bmod 1\\,000\\,000\\,007 = 832\\,833\\,871 です。

S(50\\,000\\,000)\bmod 1\\,000\\,000\\,007 を求めなさい。

1 π は素数計数関数を意味します。すなわち、π(n)n 以下の素数の数です。

--hints--

consecutiveDieThrows()653972374 を返す必要があります。

assert.strictEqual(consecutiveDieThrows(), 653972374);

--seed--

--seed-contents--

function consecutiveDieThrows() {

  return true;
}

consecutiveDieThrows();

--solutions--

// solution required