这题严格来说我不会,不过看完题第一反应就是直接看第一个数是如何变化的,然后我就打了个小函数,打完以后交上去准备继续测试找规律,结果一看居然直接就AC了。。。太假了。。

#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
using namespace std;
int getM(int N) {
    int i = 1;
    int ret = 1;
    while(i != N + 1) {
        ret++;
        if(i <= N) {
            i = i * 2;
        }else {
            i = 2 * (i - N - 1) + 1;
        }
    }
    return ret;
}
int main() {
#ifndef ONLINE_JUDGE
    freopen("data.in", "r", stdin);
#endif
    int N;
    while(scanf("%d", &N) == 1) {
         printf("%d\n", getM(N));
    }
    return 0;
}

 

相关文章:

  • 2021-12-09
  • 2022-01-18
  • 2021-12-29
  • 2021-06-02
  • 2022-12-23
  • 2021-07-14
  • 2021-08-27
  • 2022-12-23
猜你喜欢
  • 2021-10-25
  • 2022-12-23
  • 2022-12-23
  • 2021-10-21
  • 2021-12-03
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案