Last active
December 18, 2015 07:17
-
-
Save bellflower2015/f3f3514a0c72fcd4ce8b to your computer and use it in GitHub Desktop.
マヨイドーロ問題 解答 (初期リビジョン=提出時のコード) - https://codeiq.jp/q/2549
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$N = fgets(STDIN); | |
if ($N <= 0) $P = 0; | |
else { | |
$P = $p = 2; | |
$n = intval( ($N-1) / 2 ); | |
for ($i = 1, $x = 1; $i <= $n; $i++) { | |
$x = bcadd($x, $p); | |
$p = bcadd($x, $p); | |
$P = bcadd($P, $p); | |
} | |
} | |
echo $P; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment