Skip to content

Instantly share code, notes, and snippets.

@kevtainer
Created July 7, 2014 14:37
Show Gist options
  • Save kevtainer/2b8d3cf58169c8e48d99 to your computer and use it in GitHub Desktop.
Save kevtainer/2b8d3cf58169c8e48d99 to your computer and use it in GitHub Desktop.
<?php
while($f = fgets(STDIN)){
$input[] = (int)$f;
}
for($testcases=$input[0],$i=0;$i<$testcases;$i++) {
$out = 1;
for($cycles=$input[$i+1],$cycle_count=0;$cycle_count <= $cycles;$cycle_count++) {
if ($cycle_count != 0) {
if ($cycle_count%2==1) {
$out*=2;
} else {
$out+=1;
}
}
}
echo $out."\n";
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment