Created
July 12, 2023 09:31
-
-
Save ashumeow/022ec30ef21ce547ff0c05d2436b966d to your computer and use it in GitHub Desktop.
codechef problem
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 | |
// problem | |
// Alice adds the numbers to list in the following order | |
// [1,4,7,10,2,5,8,3,6,9] | |
// The 7th number in the list is 8 | |
// solution | |
$b=[1,4,7,10,2,5,8,3,6,9]; | |
$n = intval(trim(fgets(STDIN))); | |
$arr_temp = rtrim(fgets(STDIN)); | |
$arr = array_map('intval', preg_split('/ /', $arr_temp, -1, PREG_SPLIT_NO_EMPTY)); | |
$c=count($arr)-1; | |
$a=0; | |
if($c<count($b)) { | |
$d=$arr[$c]-1; | |
$a=$b[$d]; | |
} | |
echo $a; | |
// 8 | |
// | |
// ashumeow | |
// | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment