Skip to content

Commit 152ddcc

Browse files
authored
Merge pull request #16 from openset/master
refactor: StealingApples
2 parents 3f5fdb7 + 5afcdc5 commit 152ddcc

File tree

1 file changed

+24
-1
lines changed

1 file changed

+24
-1
lines changed

package/Other/StealingApples.php

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,4 +43,27 @@
4343
}
4444
}
4545
$i++;
46-
}
46+
}
47+
48+
// +----------------------------------------------------------------------
49+
// | 方法二
50+
// +----------------------------------------------------------------------
51+
/**
52+
* @author Openset <[email protected]>
53+
* @date 2017/9/7
54+
* @param int $n N个人
55+
*/
56+
for ($r = 1, $n = 5; ; $r++) {
57+
$t = $r;
58+
for ($i = 0; $i <= $n; $i++) {
59+
if ($t % 5 == 1) {
60+
$t = $t - round($t / 5) - 1;
61+
} else {
62+
continue 2;
63+
}
64+
}
65+
echo $r;
66+
break;
67+
}
68+
69+
//15621

0 commit comments

Comments
 (0)