Skip to content

Instantly share code, notes, and snippets.

@bellflower2015
Last active December 18, 2015 07:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bellflower2015/f3f3514a0c72fcd4ce8b to your computer and use it in GitHub Desktop.
Save bellflower2015/f3f3514a0c72fcd4ce8b to your computer and use it in GitHub Desktop.
マヨイドーロ問題 解答 (初期リビジョン=提出時のコード) - https://codeiq.jp/q/2549
<?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