//
// main.c
// 단기 연구 과제
// Created by Shiro Nai on 07/05/2019.
// Copyright © 2019 Shiro Nai. All rights
// reserved.
#include <stdio.h>
#include <math.h>
int main(int argc, const char * argv[]) {
double n;
printf("How many people?");
scanf("%lf", &n);
int k = floor(log10(n)/log10(2));
printf("The last standing person's number is %lf.", (2*(n-(2^k)))+1);
return 0;
}
输出与我预期的不同。例如,当n
=5 时,答案是 3,但我得到 11 的输出。